Skip to content

coverage: Unify tests/coverage-map and tests/run-coverage into tests/coverage #117484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
coverage: Set up a macro for declaring unified coverage test suites
  • Loading branch information
Zalathar committed Nov 7, 2023
commit aea7c27eae5e34b11c64ec6d11c75627ef24f8b1
53 changes: 53 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,47 @@ macro_rules! test_definitions {
};
}

/// Declares an alias for running the [`Coverage`] tests in only one mode.
/// Adapted from [`test_definitions`].
macro_rules! coverage_test_alias {
($name:ident {
alias_and_mode: $alias_and_mode:expr,
default: $default:expr,
only_hosts: $only_hosts:expr $(,)?
}) => {
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct $name {
pub compiler: Compiler,
pub target: TargetSelection,
}

impl $name {
const MODE: &'static str = $alias_and_mode;
}

impl Step for $name {
type Output = ();
const DEFAULT: bool = $default;
const ONLY_HOSTS: bool = $only_hosts;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.alias($alias_and_mode)
}

fn make_run(run: RunConfig<'_>) {
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());

run.builder.ensure($name { compiler, target: run.target });
}

fn run(self, builder: &Builder<'_>) {
Coverage { compiler: self.compiler, target: self.target }
.run_unified_suite(builder, Self::MODE)
}
}
};
}

default_test!(Ui { path: "tests/ui", mode: "ui", suite: "ui" });

default_test!(RunPassValgrind {
Expand Down Expand Up @@ -1361,7 +1402,19 @@ pub struct Coverage {
}

impl Coverage {
const PATH: &'static str = "tests/coverage";
const SUITE: &'static str = "coverage";

fn run_unified_suite(&self, builder: &Builder<'_>, mode: &'static str) {
builder.ensure(Compiletest {
compiler: self.compiler,
target: self.target,
mode,
suite: Self::SUITE,
path: Self::PATH,
compare_mode: None,
})
}
}

impl Step for Coverage {
Expand Down