Skip to content

Commit 1e37bbe

Browse files
committed
Allow macro-declared test steps to have docstrings and attributes
1 parent 7b7f634 commit 1e37bbe

File tree

1 file changed

+32
-21
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+32
-21
lines changed

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

+32-21
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
11361136
/// Declares a test step that invokes compiletest on a particular test suite.
11371137
macro_rules! test {
11381138
(
1139+
$( #[$attr:meta] )* // allow docstrings and attributes
11391140
$name:ident {
11401141
path: $path:expr,
11411142
mode: $mode:expr,
@@ -1146,6 +1147,7 @@ macro_rules! test {
11461147
$( , )? // optional trailing comma
11471148
}
11481149
) => {
1150+
$( #[$attr] )*
11491151
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11501152
pub struct $name {
11511153
pub compiler: Compiler,
@@ -1194,11 +1196,16 @@ macro_rules! test {
11941196
/// Declares an alias for running the [`Coverage`] tests in only one mode.
11951197
/// Adapted from [`test`].
11961198
macro_rules! coverage_test_alias {
1197-
($name:ident {
1198-
alias_and_mode: $alias_and_mode:expr, // &'static str
1199-
default: $default:expr, // bool
1200-
only_hosts: $only_hosts:expr $(,)? // bool
1201-
}) => {
1199+
(
1200+
$( #[$attr:meta] )* // allow docstrings and attributes
1201+
$name:ident {
1202+
alias_and_mode: $alias_and_mode:expr, // &'static str
1203+
default: $default:expr, // bool
1204+
only_hosts: $only_hosts:expr // bool
1205+
$( , )? // optional trailing comma
1206+
}
1207+
) => {
1208+
$( #[$attr] )*
12021209
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12031210
pub struct $name {
12041211
pub compiler: Compiler,
@@ -1549,22 +1556,26 @@ impl Step for Coverage {
15491556
}
15501557
}
15511558

1552-
// Runs `tests/coverage` in "coverage-map" mode only.
1553-
// Used by `x test` and `x test coverage-map`.
1554-
coverage_test_alias!(CoverageMap {
1555-
alias_and_mode: "coverage-map",
1556-
default: true,
1557-
only_hosts: false,
1558-
});
1559-
// Runs `tests/coverage` in "coverage-run" mode only.
1560-
// Used by `x test` and `x test coverage-run`.
1561-
coverage_test_alias!(CoverageRun {
1562-
alias_and_mode: "coverage-run",
1563-
default: true,
1564-
// Compiletest knows how to automatically skip these tests when cross-compiling,
1565-
// but skipping the whole step here makes it clearer that they haven't run at all.
1566-
only_hosts: true,
1567-
});
1559+
coverage_test_alias! {
1560+
/// Runs the `tests/coverage` test suite in "coverage-map" mode only.
1561+
/// Used by `x test` and `x test coverage-map`.
1562+
CoverageMap {
1563+
alias_and_mode: "coverage-map",
1564+
default: true,
1565+
only_hosts: false,
1566+
}
1567+
}
1568+
coverage_test_alias! {
1569+
/// Runs the `tests/coverage` test suite in "coverage-run" mode only.
1570+
/// Used by `x test` and `x test coverage-run`.
1571+
CoverageRun {
1572+
alias_and_mode: "coverage-run",
1573+
default: true,
1574+
// Compiletest knows how to automatically skip these tests when cross-compiling,
1575+
// but skipping the whole step here makes it clearer that they haven't run at all.
1576+
only_hosts: true,
1577+
}
1578+
}
15681579

15691580
test!(CoverageRunRustdoc {
15701581
path: "tests/coverage-run-rustdoc",

0 commit comments

Comments
 (0)