Skip to content

Commit

Permalink
coverage: Add ./x.py test coverage, an alias for coverage-map and…
Browse files Browse the repository at this point in the history
… `run-coverage`
  • Loading branch information
Zalathar committed Nov 7, 2023
1 parent e585a99 commit 3509aed
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ impl<'a> Builder<'a> {
test::Tidy,
test::Ui,
test::RunPassValgrind,
test::Coverage,
test::CoverageMap,
test::RunCoverage,
test::MirOpt,
Expand Down

0 comments on commit 3509aed

Please sign in to comment.