Skip to content

Commit fc4fdb5

Browse files
committed
Move the test! macro closer to its usages
1 parent 80b5ca3 commit fc4fdb5

File tree

1 file changed

+70
-70
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+70
-70
lines changed

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

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,76 +1316,6 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
13161316
}
13171317
}
13181318

1319-
fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
1320-
builder.out.join(host).join("test")
1321-
}
1322-
1323-
/// Declares a test step that invokes compiletest on a particular test suite.
1324-
macro_rules! test {
1325-
(
1326-
$( #[$attr:meta] )* // allow docstrings and attributes
1327-
$name:ident {
1328-
path: $path:expr,
1329-
mode: $mode:expr,
1330-
suite: $suite:expr,
1331-
default: $default:expr
1332-
$( , IS_HOST: $IS_HOST:expr )? // default: false
1333-
$( , compare_mode: $compare_mode:expr )? // default: None
1334-
$( , )? // optional trailing comma
1335-
}
1336-
) => {
1337-
$( #[$attr] )*
1338-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1339-
pub struct $name {
1340-
pub compiler: Compiler,
1341-
pub target: TargetSelection,
1342-
}
1343-
1344-
impl Step for $name {
1345-
type Output = ();
1346-
const DEFAULT: bool = $default;
1347-
const IS_HOST: bool = (const {
1348-
#[allow(unused_assignments, unused_mut)]
1349-
let mut value = false;
1350-
$( value = $IS_HOST; )?
1351-
value
1352-
});
1353-
1354-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1355-
run.suite_path($path)
1356-
}
1357-
1358-
fn make_run(run: RunConfig<'_>) {
1359-
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1360-
1361-
run.builder.ensure($name { compiler, target: run.target });
1362-
}
1363-
1364-
fn run(self, builder: &Builder<'_>) {
1365-
builder.ensure(Compiletest {
1366-
compiler: self.compiler,
1367-
target: self.target,
1368-
mode: $mode,
1369-
suite: $suite,
1370-
path: $path,
1371-
compare_mode: (const {
1372-
#[allow(unused_assignments, unused_mut)]
1373-
let mut value = None;
1374-
$( value = $compare_mode; )?
1375-
value
1376-
}),
1377-
})
1378-
}
1379-
1380-
fn metadata(&self) -> Option<StepMetadata> {
1381-
Some(
1382-
StepMetadata::test(stringify!($name), self.target)
1383-
)
1384-
}
1385-
}
1386-
};
1387-
}
1388-
13891319
/// Runs `cargo test` on the `src/tools/run-make-support` crate.
13901320
/// That crate is used by run-make tests.
13911321
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -1462,6 +1392,76 @@ impl Step for CrateBuildHelper {
14621392
}
14631393
}
14641394

1395+
fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
1396+
builder.out.join(host).join("test")
1397+
}
1398+
1399+
/// Declares a test step that invokes compiletest on a particular test suite.
1400+
macro_rules! test {
1401+
(
1402+
$( #[$attr:meta] )* // allow docstrings and attributes
1403+
$name:ident {
1404+
path: $path:expr,
1405+
mode: $mode:expr,
1406+
suite: $suite:expr,
1407+
default: $default:expr
1408+
$( , IS_HOST: $IS_HOST:expr )? // default: false
1409+
$( , compare_mode: $compare_mode:expr )? // default: None
1410+
$( , )? // optional trailing comma
1411+
}
1412+
) => {
1413+
$( #[$attr] )*
1414+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1415+
pub struct $name {
1416+
pub compiler: Compiler,
1417+
pub target: TargetSelection,
1418+
}
1419+
1420+
impl Step for $name {
1421+
type Output = ();
1422+
const DEFAULT: bool = $default;
1423+
const IS_HOST: bool = (const {
1424+
#[allow(unused_assignments, unused_mut)]
1425+
let mut value = false;
1426+
$( value = $IS_HOST; )?
1427+
value
1428+
});
1429+
1430+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
1431+
run.suite_path($path)
1432+
}
1433+
1434+
fn make_run(run: RunConfig<'_>) {
1435+
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1436+
1437+
run.builder.ensure($name { compiler, target: run.target });
1438+
}
1439+
1440+
fn run(self, builder: &Builder<'_>) {
1441+
builder.ensure(Compiletest {
1442+
compiler: self.compiler,
1443+
target: self.target,
1444+
mode: $mode,
1445+
suite: $suite,
1446+
path: $path,
1447+
compare_mode: (const {
1448+
#[allow(unused_assignments, unused_mut)]
1449+
let mut value = None;
1450+
$( value = $compare_mode; )?
1451+
value
1452+
}),
1453+
})
1454+
}
1455+
1456+
fn metadata(&self) -> Option<StepMetadata> {
1457+
Some(
1458+
StepMetadata::test(stringify!($name), self.target)
1459+
)
1460+
}
1461+
}
1462+
};
1463+
}
1464+
14651465
test!(Ui { path: "tests/ui", mode: "ui", suite: "ui", default: true });
14661466

14671467
test!(Crashes { path: "tests/crashes", mode: "crashes", suite: "crashes", default: true });

0 commit comments

Comments
 (0)