Skip to content

Commit aea7c27

Browse files
committedNov 7, 2023
coverage: Set up a macro for declaring unified coverage test suites
1 parent 3509aed commit aea7c27

File tree

1 file changed

+53
-0
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+53
-0
lines changed
 

‎src/bootstrap/src/core/build_steps/test.rs

+53
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,47 @@ macro_rules! test_definitions {
13051305
};
13061306
}
13071307

1308+
/// Declares an alias for running the [`Coverage`] tests in only one mode.
1309+
/// Adapted from [`test_definitions`].
1310+
macro_rules! coverage_test_alias {
1311+
($name:ident {
1312+
alias_and_mode: $alias_and_mode:expr,
1313+
default: $default:expr,
1314+
only_hosts: $only_hosts:expr $(,)?
1315+
}) => {
1316+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1317+
pub struct $name {
1318+
pub compiler: Compiler,
1319+
pub target: TargetSelection,
1320+
}
1321+
1322+
impl $name {
1323+
const MODE: &'static str = $alias_and_mode;
1324+
}
1325+
1326+
impl Step for $name {
1327+
type Output = ();
1328+
const DEFAULT: bool = $default;
1329+
const ONLY_HOSTS: bool = $only_hosts;
1330+
1331+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1332+
run.alias($alias_and_mode)
1333+
}
1334+
1335+
fn make_run(run: RunConfig<'_>) {
1336+
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1337+
1338+
run.builder.ensure($name { compiler, target: run.target });
1339+
}
1340+
1341+
fn run(self, builder: &Builder<'_>) {
1342+
Coverage { compiler: self.compiler, target: self.target }
1343+
.run_unified_suite(builder, Self::MODE)
1344+
}
1345+
}
1346+
};
1347+
}
1348+
13081349
default_test!(Ui { path: "tests/ui", mode: "ui", suite: "ui" });
13091350

13101351
default_test!(RunPassValgrind {
@@ -1361,7 +1402,19 @@ pub struct Coverage {
13611402
}
13621403

13631404
impl Coverage {
1405+
const PATH: &'static str = "tests/coverage";
13641406
const SUITE: &'static str = "coverage";
1407+
1408+
fn run_unified_suite(&self, builder: &Builder<'_>, mode: &'static str) {
1409+
builder.ensure(Compiletest {
1410+
compiler: self.compiler,
1411+
target: self.target,
1412+
mode,
1413+
suite: Self::SUITE,
1414+
path: Self::PATH,
1415+
compare_mode: None,
1416+
})
1417+
}
13651418
}
13661419

13671420
impl Step for Coverage {

0 commit comments

Comments
 (0)