@@ -1133,69 +1133,21 @@ fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
1133
1133
builder. out . join ( host) . join ( "test" )
1134
1134
}
1135
1135
1136
- macro_rules! default_test {
1137
- ( $name: ident { path: $path: expr, mode: $mode: expr, suite: $suite: expr } ) => {
1138
- test!( $name { path: $path, mode: $mode, suite: $suite, default : true , host: false } ) ;
1139
- } ;
1140
- }
1141
-
1142
- macro_rules! default_test_with_compare_mode {
1143
- ( $name: ident { path: $path: expr, mode: $mode: expr, suite: $suite: expr,
1144
- compare_mode: $compare_mode: expr } ) => {
1145
- test_with_compare_mode!( $name {
1146
- path: $path,
1147
- mode: $mode,
1148
- suite: $suite,
1149
- default : true ,
1150
- host: false ,
1151
- compare_mode: $compare_mode
1152
- } ) ;
1153
- } ;
1154
- }
1155
-
1156
- macro_rules! host_test {
1157
- ( $name: ident { path: $path: expr, mode: $mode: expr, suite: $suite: expr } ) => {
1158
- test!( $name { path: $path, mode: $mode, suite: $suite, default : true , host: true } ) ;
1159
- } ;
1160
- }
1161
-
1136
+ /// Declares a test step that invokes compiletest on a particular test suite.
1162
1137
macro_rules! test {
1163
- ( $name: ident { path: $path: expr, mode: $mode: expr, suite: $suite: expr, default : $default: expr,
1164
- host: $host: expr } ) => {
1165
- test_definitions!( $name {
1166
- path: $path,
1167
- mode: $mode,
1168
- suite: $suite,
1169
- default : $default,
1170
- host: $host,
1171
- compare_mode: None
1172
- } ) ;
1173
- } ;
1174
- }
1175
-
1176
- macro_rules! test_with_compare_mode {
1177
- ( $name: ident { path: $path: expr, mode: $mode: expr, suite: $suite: expr, default : $default: expr,
1178
- host: $host: expr, compare_mode: $compare_mode: expr } ) => {
1179
- test_definitions!( $name {
1180
- path: $path,
1181
- mode: $mode,
1182
- suite: $suite,
1183
- default : $default,
1184
- host: $host,
1185
- compare_mode: Some ( $compare_mode)
1186
- } ) ;
1187
- } ;
1188
- }
1189
-
1190
- macro_rules! test_definitions {
1191
- ( $name: ident {
1192
- path: $path: expr,
1193
- mode: $mode: expr,
1194
- suite: $suite: expr,
1195
- default : $default: expr,
1196
- host: $host: expr,
1197
- compare_mode: $compare_mode: expr
1198
- } ) => {
1138
+ (
1139
+ $( #[ $attr: meta] ) * // allow docstrings and attributes
1140
+ $name: ident {
1141
+ path: $path: expr,
1142
+ mode: $mode: expr,
1143
+ suite: $suite: expr,
1144
+ default : $default: expr
1145
+ $( , only_hosts: $only_hosts: expr ) ? // default: false
1146
+ $( , compare_mode: $compare_mode: expr ) ? // default: None
1147
+ $( , ) ? // optional trailing comma
1148
+ }
1149
+ ) => {
1150
+ $( #[ $attr] ) *
1199
1151
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1200
1152
pub struct $name {
1201
1153
pub compiler: Compiler ,
@@ -1205,7 +1157,12 @@ macro_rules! test_definitions {
1205
1157
impl Step for $name {
1206
1158
type Output = ( ) ;
1207
1159
const DEFAULT : bool = $default;
1208
- const ONLY_HOSTS : bool = $host;
1160
+ const ONLY_HOSTS : bool = ( const {
1161
+ #[ allow( unused_assignments, unused_mut) ]
1162
+ let mut value = false ;
1163
+ $( value = $only_hosts; ) ?
1164
+ value
1165
+ } ) ;
1209
1166
1210
1167
fn should_run( run: ShouldRun <' _>) -> ShouldRun <' _> {
1211
1168
run. suite_path( $path)
@@ -1224,21 +1181,31 @@ macro_rules! test_definitions {
1224
1181
mode: $mode,
1225
1182
suite: $suite,
1226
1183
path: $path,
1227
- compare_mode: $compare_mode,
1184
+ compare_mode: ( const {
1185
+ #[ allow( unused_assignments, unused_mut) ]
1186
+ let mut value = None ;
1187
+ $( value = $compare_mode; ) ?
1188
+ value
1189
+ } ) ,
1228
1190
} )
1229
1191
}
1230
1192
}
1231
1193
} ;
1232
1194
}
1233
1195
1234
1196
/// Declares an alias for running the [`Coverage`] tests in only one mode.
1235
- /// Adapted from [`test_definitions `].
1197
+ /// Adapted from [`test `].
1236
1198
macro_rules! coverage_test_alias {
1237
- ( $name: ident {
1238
- alias_and_mode: $alias_and_mode: expr, // &'static str
1239
- default : $default: expr, // bool
1240
- only_hosts: $only_hosts: expr $( , ) ? // bool
1241
- } ) => {
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] ) *
1242
1209
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1243
1210
pub struct $name {
1244
1211
pub compiler: Compiler ,
@@ -1410,37 +1377,74 @@ impl Step for CrateBuildHelper {
1410
1377
}
1411
1378
}
1412
1379
1413
- default_test ! ( Ui { path: "tests/ui" , mode: "ui" , suite: "ui" } ) ;
1380
+ test ! ( Ui { path: "tests/ui" , mode: "ui" , suite: "ui" , default : true } ) ;
1414
1381
1415
- default_test ! ( Crashes { path: "tests/crashes" , mode: "crashes" , suite: "crashes" } ) ;
1382
+ test ! ( Crashes { path: "tests/crashes" , mode: "crashes" , suite: "crashes" , default : true } ) ;
1416
1383
1417
- default_test ! ( Codegen { path: "tests/codegen" , mode: "codegen" , suite: "codegen" } ) ;
1384
+ test ! ( Codegen { path: "tests/codegen" , mode: "codegen" , suite: "codegen" , default : true } ) ;
1418
1385
1419
- default_test ! ( CodegenUnits {
1386
+ test ! ( CodegenUnits {
1420
1387
path: "tests/codegen-units" ,
1421
1388
mode: "codegen-units" ,
1422
- suite: "codegen-units"
1389
+ suite: "codegen-units" ,
1390
+ default : true ,
1423
1391
} ) ;
1424
1392
1425
- default_test ! ( Incremental { path: "tests/incremental" , mode: "incremental" , suite: "incremental" } ) ;
1393
+ test ! ( Incremental {
1394
+ path: "tests/incremental" ,
1395
+ mode: "incremental" ,
1396
+ suite: "incremental" ,
1397
+ default : true ,
1398
+ } ) ;
1426
1399
1427
- default_test_with_compare_mode ! ( Debuginfo {
1400
+ test ! ( Debuginfo {
1428
1401
path: "tests/debuginfo" ,
1429
1402
mode: "debuginfo" ,
1430
1403
suite: "debuginfo" ,
1431
- compare_mode: "split-dwarf"
1404
+ default : true ,
1405
+ compare_mode: Some ( "split-dwarf" ) ,
1432
1406
} ) ;
1433
1407
1434
- host_test ! ( UiFullDeps { path: "tests/ui-fulldeps" , mode: "ui" , suite: "ui-fulldeps" } ) ;
1408
+ test ! ( UiFullDeps {
1409
+ path: "tests/ui-fulldeps" ,
1410
+ mode: "ui" ,
1411
+ suite: "ui-fulldeps" ,
1412
+ default : true ,
1413
+ only_hosts: true ,
1414
+ } ) ;
1435
1415
1436
- host_test ! ( Rustdoc { path: "tests/rustdoc" , mode: "rustdoc" , suite: "rustdoc" } ) ;
1437
- host_test ! ( RustdocUi { path: "tests/rustdoc-ui" , mode: "ui" , suite: "rustdoc-ui" } ) ;
1416
+ test ! ( Rustdoc {
1417
+ path: "tests/rustdoc" ,
1418
+ mode: "rustdoc" ,
1419
+ suite: "rustdoc" ,
1420
+ default : true ,
1421
+ only_hosts: true ,
1422
+ } ) ;
1423
+ test ! ( RustdocUi {
1424
+ path: "tests/rustdoc-ui" ,
1425
+ mode: "ui" ,
1426
+ suite: "rustdoc-ui" ,
1427
+ default : true ,
1428
+ only_hosts: true ,
1429
+ } ) ;
1438
1430
1439
- host_test ! ( RustdocJson { path: "tests/rustdoc-json" , mode: "rustdoc-json" , suite: "rustdoc-json" } ) ;
1431
+ test ! ( RustdocJson {
1432
+ path: "tests/rustdoc-json" ,
1433
+ mode: "rustdoc-json" ,
1434
+ suite: "rustdoc-json" ,
1435
+ default : true ,
1436
+ only_hosts: true ,
1437
+ } ) ;
1440
1438
1441
- host_test ! ( Pretty { path: "tests/pretty" , mode: "pretty" , suite: "pretty" } ) ;
1439
+ test ! ( Pretty {
1440
+ path: "tests/pretty" ,
1441
+ mode: "pretty" ,
1442
+ suite: "pretty" ,
1443
+ default : true ,
1444
+ only_hosts: true ,
1445
+ } ) ;
1442
1446
1443
- /// Special-handling is needed for `run-make`, so don't use `default_test ` for defining `RunMake`
1447
+ /// Special-handling is needed for `run-make`, so don't use `test! ` for defining `RunMake`
1444
1448
/// tests.
1445
1449
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
1446
1450
pub struct RunMake {
@@ -1475,7 +1479,7 @@ impl Step for RunMake {
1475
1479
}
1476
1480
}
1477
1481
1478
- default_test ! ( Assembly { path: "tests/assembly" , mode: "assembly" , suite: "assembly" } ) ;
1482
+ test ! ( Assembly { path: "tests/assembly" , mode: "assembly" , suite: "assembly" , default : true } ) ;
1479
1483
1480
1484
/// Coverage tests are a bit more complicated than other test suites, because
1481
1485
/// we want to run the same set of test files in multiple different modes,
@@ -1552,27 +1556,33 @@ impl Step for Coverage {
1552
1556
}
1553
1557
}
1554
1558
1555
- // Runs `tests/coverage` in "coverage-map" mode only.
1556
- // Used by `x test` and `x test coverage-map`.
1557
- coverage_test_alias ! ( CoverageMap {
1558
- alias_and_mode: "coverage-map" ,
1559
- default : true ,
1560
- only_hosts: false ,
1561
- } ) ;
1562
- // Runs `tests/coverage` in "coverage-run" mode only.
1563
- // Used by `x test` and `x test coverage-run`.
1564
- coverage_test_alias ! ( CoverageRun {
1565
- alias_and_mode: "coverage-run" ,
1566
- default : true ,
1567
- // Compiletest knows how to automatically skip these tests when cross-compiling,
1568
- // but skipping the whole step here makes it clearer that they haven't run at all.
1569
- only_hosts: true ,
1570
- } ) ;
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
+ }
1571
1579
1572
- host_test ! ( CoverageRunRustdoc {
1580
+ test ! ( CoverageRunRustdoc {
1573
1581
path: "tests/coverage-run-rustdoc" ,
1574
1582
mode: "coverage-run" ,
1575
- suite: "coverage-run-rustdoc"
1583
+ suite: "coverage-run-rustdoc" ,
1584
+ default : true ,
1585
+ only_hosts: true ,
1576
1586
} ) ;
1577
1587
1578
1588
// For the mir-opt suite we do not use macros, as we need custom behavior when blessing.
0 commit comments