From 3509aed632dd7badac18b071bcd7e1ca53f9d1c6 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 1 Nov 2023 20:02:09 +1100 Subject: [PATCH] coverage: Add `./x.py test coverage`, an alias for `coverage-map` and `run-coverage` --- src/bootstrap/src/core/build_steps/test.rs | 50 ++++++++++++++++++++++ src/bootstrap/src/core/builder.rs | 1 + 2 files changed, 51 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index e2b515a30867b..c964d220cc3da 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1349,6 +1349,56 @@ host_test!(RunMakeFullDeps { default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly" }); +/// Custom test step that is responsible for running the coverage tests +/// in multiple different modes. +/// +/// Each individual mode also has its own alias that will run the tests in +/// just that mode. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct Coverage { + pub compiler: Compiler, + pub target: TargetSelection, +} + +impl Coverage { + const SUITE: &'static str = "coverage"; +} + +impl Step for Coverage { + type Output = (); + const DEFAULT: bool = false; + const ONLY_HOSTS: bool = false; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias(Self::SUITE) + } + + fn make_run(run: RunConfig<'_>) { + let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); + + run.builder.ensure(Coverage { compiler, target: run.target }); + } + + fn run(self, builder: &Builder<'_>) { + builder.ensure(Compiletest { + compiler: self.compiler, + target: self.target, + mode: "coverage-map", + suite: "coverage-map", + path: "tests/coverage-map", + compare_mode: None, + }); + builder.ensure(Compiletest { + compiler: self.compiler, + target: self.target, + mode: "run-coverage", + suite: "run-coverage", + path: "tests/run-coverage", + compare_mode: None, + }); + } +} + default_test!(CoverageMap { path: "tests/coverage-map", mode: "coverage-map", diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 44cdbe38de365..38eb46332738a 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -727,6 +727,7 @@ impl<'a> Builder<'a> { test::Tidy, test::Ui, test::RunPassValgrind, + test::Coverage, test::CoverageMap, test::RunCoverage, test::MirOpt,