@@ -1242,8 +1242,28 @@ mod staging {
1242
1242
use crate :: core:: builder:: tests:: {
1243
1243
TEST_TRIPLE_1 , configure, configure_with_args, render_steps, run_build,
1244
1244
} ;
1245
+ use crate :: utils:: cache:: Cache ;
1245
1246
use crate :: utils:: tests:: { ConfigBuilder , TestCtx } ;
1246
1247
1248
+ #[ test]
1249
+ fn build_compiler_no_stage ( ) {
1250
+ let ctx = TestCtx :: new ( ) ;
1251
+ insta:: assert_snapshot!(
1252
+ ctx. config( "build" )
1253
+ . path( "compiler" )
1254
+ . get_steps( ) , @r"
1255
+ [build] llvm <host>
1256
+ [build] rustc 0 <host> -> rustc 1 <host>
1257
+ " ) ;
1258
+ }
1259
+
1260
+ #[ test]
1261
+ #[ should_panic]
1262
+ fn build_compiler_stage_0 ( ) {
1263
+ let ctx = TestCtx :: new ( ) ;
1264
+ ctx. config ( "build" ) . path ( "compiler" ) . stage ( 0 ) . run ( ) ;
1265
+ }
1266
+
1247
1267
#[ test]
1248
1268
fn build_compiler_stage_1 ( ) {
1249
1269
let ctx = TestCtx :: new ( ) ;
@@ -1252,22 +1272,173 @@ mod staging {
1252
1272
. path( "compiler" )
1253
1273
. stage( 1 )
1254
1274
. get_steps( ) , @r"
1255
- [build] rustc 0 <host> -> std 0 <host>
1256
1275
[build] llvm <host>
1257
1276
[build] rustc 0 <host> -> rustc 1 <host>
1277
+ " ) ;
1278
+ }
1279
+
1280
+ #[ test]
1281
+ fn build_compiler_stage_2 ( ) {
1282
+ let ctx = TestCtx :: new ( ) ;
1283
+ insta:: assert_snapshot!(
1284
+ ctx. config( "build" )
1285
+ . path( "compiler" )
1286
+ . stage( 2 )
1287
+ . get_steps( ) , @r"
1288
+ [build] llvm <host>
1258
1289
[build] rustc 0 <host> -> rustc 1 <host>
1290
+ [build] rustc 1 <host> -> std 1 <host>
1291
+ [build] rustc 1 <host> -> rustc 2 <host>
1259
1292
" ) ;
1260
1293
}
1261
1294
1295
+ #[ test]
1296
+ fn build_library_no_stage ( ) {
1297
+ let ctx = TestCtx :: new ( ) ;
1298
+ insta:: assert_snapshot!(
1299
+ ctx. config( "build" )
1300
+ . path( "library" )
1301
+ . get_steps( ) , @r"
1302
+ [build] llvm <host>
1303
+ [build] rustc 0 <host> -> rustc 1 <host>
1304
+ [build] rustc 1 <host> -> std 1 <host>
1305
+ " ) ;
1306
+ }
1307
+
1308
+ #[ test]
1309
+ #[ should_panic]
1310
+ fn build_library_stage_0 ( ) {
1311
+ let ctx = TestCtx :: new ( ) ;
1312
+ ctx. config ( "build" ) . path ( "library" ) . stage ( 0 ) . run ( ) ;
1313
+ }
1314
+
1315
+ #[ test]
1316
+ fn build_library_stage_1 ( ) {
1317
+ let ctx = TestCtx :: new ( ) ;
1318
+ insta:: assert_snapshot!(
1319
+ ctx. config( "build" )
1320
+ . path( "library" )
1321
+ . stage( 1 )
1322
+ . get_steps( ) , @r"
1323
+ [build] llvm <host>
1324
+ [build] rustc 0 <host> -> rustc 1 <host>
1325
+ [build] rustc 1 <host> -> std 1 <host>
1326
+ " ) ;
1327
+ }
1328
+
1329
+ #[ test]
1330
+ fn build_library_stage_2 ( ) {
1331
+ let ctx = TestCtx :: new ( ) ;
1332
+ insta:: assert_snapshot!(
1333
+ ctx. config( "build" )
1334
+ . path( "library" )
1335
+ . stage( 2 )
1336
+ . get_steps( ) , @r"
1337
+ [build] llvm <host>
1338
+ [build] rustc 0 <host> -> rustc 1 <host>
1339
+ [build] rustc 1 <host> -> std 1 <host>
1340
+ [build] rustc 1 <host> -> rustc 2 <host>
1341
+ [build] rustc 2 <host> -> std 2 <host>
1342
+ " ) ;
1343
+ }
1344
+
1345
+ #[ test]
1346
+ fn build_miri_no_stage ( ) {
1347
+ let ctx = TestCtx :: new ( ) ;
1348
+ insta:: assert_snapshot!(
1349
+ ctx. config( "build" )
1350
+ . path( "miri" )
1351
+ . get_steps( ) , @r"
1352
+ [build] llvm <host>
1353
+ [build] rustc 0 <host> -> rustc 1 <host>
1354
+ " ) ;
1355
+ }
1356
+
1357
+ #[ test]
1358
+ #[ should_panic]
1359
+ fn build_miri_stage_0 ( ) {
1360
+ let ctx = TestCtx :: new ( ) ;
1361
+ ctx. config ( "build" ) . path ( "miri" ) . stage ( 0 ) . run ( ) ;
1362
+ }
1363
+
1364
+ #[ test]
1365
+ fn build_miri_stage_1 ( ) {
1366
+ let ctx = TestCtx :: new ( ) ;
1367
+ insta:: assert_snapshot!(
1368
+ ctx. config( "build" )
1369
+ . path( "miri" )
1370
+ . stage( 1 )
1371
+ . get_steps( ) , @r"
1372
+ [build] llvm <host>
1373
+ [build] rustc 0 <host> -> rustc 1 <host>
1374
+ " ) ;
1375
+ }
1376
+
1377
+ #[ test]
1378
+ fn build_miri_stage_2 ( ) {
1379
+ let ctx = TestCtx :: new ( ) ;
1380
+ insta:: assert_snapshot!(
1381
+ ctx. config( "build" )
1382
+ . path( "miri" )
1383
+ . stage( 2 )
1384
+ . get_steps( ) , @r"
1385
+ [build] llvm <host>
1386
+ [build] rustc 0 <host> -> rustc 1 <host>
1387
+ [build] rustc 1 <host> -> std 1 <host>
1388
+ [build] rustc 1 <host> -> rustc 2 <host>
1389
+ " ) ;
1390
+ }
1391
+
1392
+ #[ test]
1393
+ fn build_bootstrap_tool_no_stage ( ) {
1394
+ let ctx = TestCtx :: new ( ) ;
1395
+ insta:: assert_snapshot!(
1396
+ ctx. config( "build" )
1397
+ . path( "opt-dist" )
1398
+ . get_steps( ) , @"[build] rustc 0 <host> -> OptimizedDist <host>" ) ;
1399
+ }
1400
+
1401
+ #[ test]
1402
+ #[ should_panic]
1403
+ fn build_bootstrap_tool_stage_0 ( ) {
1404
+ let ctx = TestCtx :: new ( ) ;
1405
+ ctx. config ( "build" ) . path ( "opt-dist" ) . stage ( 0 ) . run ( ) ;
1406
+ }
1407
+
1408
+ #[ test]
1409
+ fn build_bootstrap_tool_stage_1 ( ) {
1410
+ let ctx = TestCtx :: new ( ) ;
1411
+ insta:: assert_snapshot!(
1412
+ ctx. config( "build" )
1413
+ . path( "opt-dist" )
1414
+ . stage( 1 )
1415
+ . get_steps( ) , @"[build] rustc 0 <host> -> OptimizedDist <host>" ) ;
1416
+ }
1417
+
1418
+ #[ test]
1419
+ fn build_bootstrap_tool_stage_2 ( ) {
1420
+ let ctx = TestCtx :: new ( ) ;
1421
+ insta:: assert_snapshot!(
1422
+ ctx. config( "build" )
1423
+ . path( "opt-dist" )
1424
+ . stage( 2 )
1425
+ . get_steps( ) , @"[build] rustc 0 <host> -> OptimizedDist <host>" ) ;
1426
+ }
1427
+
1262
1428
impl ConfigBuilder {
1263
- fn get_steps ( self ) -> String {
1429
+ fn run ( self ) -> Cache {
1264
1430
let config = self . create_config ( ) ;
1265
1431
1266
1432
let kind = config. cmd . kind ( ) ;
1267
1433
let build = Build :: new ( config) ;
1268
1434
let builder = Builder :: new ( & build) ;
1269
1435
builder. run_step_descriptions ( & Builder :: get_step_descriptions ( kind) , & builder. paths ) ;
1270
- render_steps ( & builder. cache . into_executed_steps ( ) )
1436
+ builder. cache
1437
+ }
1438
+
1439
+ fn get_steps ( self ) -> String {
1440
+ let cache = self . run ( ) ;
1441
+ render_steps ( & cache. into_executed_steps ( ) )
1271
1442
}
1272
1443
}
1273
1444
}
0 commit comments