@@ -1242,8 +1242,28 @@ mod staging {
12421242 use crate :: core:: builder:: tests:: {
12431243 TEST_TRIPLE_1 , configure, configure_with_args, render_steps, run_build,
12441244 } ;
1245+ use crate :: utils:: cache:: Cache ;
12451246 use crate :: utils:: tests:: { ConfigBuilder , TestCtx } ;
12461247
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+
12471267 #[ test]
12481268 fn build_compiler_stage_1 ( ) {
12491269 let ctx = TestCtx :: new ( ) ;
@@ -1252,22 +1272,173 @@ mod staging {
12521272 . path( "compiler" )
12531273 . stage( 1 )
12541274 . get_steps( ) , @r"
1255- [build] rustc 0 <host> -> std 0 <host>
12561275 [build] llvm <host>
12571276 [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>
12581289 [build] rustc 0 <host> -> rustc 1 <host>
1290+ [build] rustc 1 <host> -> std 1 <host>
1291+ [build] rustc 1 <host> -> rustc 2 <host>
12591292 " ) ;
12601293 }
12611294
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+
12621428 impl ConfigBuilder {
1263- fn get_steps ( self ) -> String {
1429+ fn run ( self ) -> Cache {
12641430 let config = self . create_config ( ) ;
12651431
12661432 let kind = config. cmd . kind ( ) ;
12671433 let build = Build :: new ( config) ;
12681434 let builder = Builder :: new ( & build) ;
12691435 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 ( ) )
12711442 }
12721443 }
12731444}
0 commit comments