Skip to content

Commit 8f4a11d

Browse files
committed
coverage: Set up a macro for declaring unified coverage test suites
1 parent 1a8fe8b commit 8f4a11d

File tree

1 file changed

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

1 file changed

+58
-0
lines changed

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

+58
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 {
@@ -1349,14 +1390,31 @@ host_test!(RunMakeFullDeps {
13491390

13501391
default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly" });
13511392

1393+
/// Custom test step that is responsible for running the coverage tests
1394+
/// in multiple different modes.
1395+
///
1396+
/// Each individual mode also has its own alias that will run the tests in
1397+
/// just that mode.
13521398
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
13531399
pub struct Coverage {
13541400
pub compiler: Compiler,
13551401
pub target: TargetSelection,
13561402
}
13571403

13581404
impl Coverage {
1405+
const PATH: &'static str = "tests/coverage";
13591406
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+
}
13601418
}
13611419

13621420
impl Step for Coverage {

0 commit comments

Comments
 (0)