@@ -8,6 +8,7 @@ use super::*;
8
8
use crate :: Flags ;
9
9
use crate :: core:: build_steps:: doc:: DocumentationFormat ;
10
10
use crate :: core:: config:: Config ;
11
+ use crate :: utils:: helpers:: get_host_target;
11
12
use crate :: utils:: tests:: git:: { GitCtx , git_test} ;
12
13
13
14
static TEST_TRIPLE_1 : & str = "i686-unknown-haiku" ;
@@ -1235,24 +1236,38 @@ fn any_debug() {
1235
1236
/// The staging tests use insta for snapshot testing.
1236
1237
/// See bootstrap's README on how to bless the snapshots.
1237
1238
mod staging {
1239
+ use crate :: Build ;
1240
+ use crate :: core:: builder:: Builder ;
1238
1241
use crate :: core:: builder:: tests:: {
1239
1242
TEST_TRIPLE_1 , configure, configure_with_args, render_steps, run_build,
1240
1243
} ;
1244
+ use crate :: utils:: tests:: ConfigBuilder ;
1241
1245
1242
1246
#[ test]
1243
1247
fn build_compiler_stage_1 ( ) {
1244
- let mut cache = run_build (
1245
- & [ "compiler" . into ( ) ] ,
1246
- configure_with_args ( & [ "build" , "--stage" , "1" ] , & [ TEST_TRIPLE_1 ] , & [ TEST_TRIPLE_1 ] ) ,
1247
- ) ;
1248
- let steps = cache. into_executed_steps ( ) ;
1249
- insta:: assert_snapshot!( render_steps( & steps) , @r"
1250
- [build] rustc 0 <target1> -> std 0 <target1>
1251
- [build] llvm <target1>
1252
- [build] rustc 0 <target1> -> rustc 1 <target1>
1253
- [build] rustc 0 <target1> -> rustc 1 <target1>
1248
+ insta:: assert_snapshot!(
1249
+ ConfigBuilder :: build( )
1250
+ . path( "compiler" )
1251
+ . stage( 1 )
1252
+ . get_steps( ) , @r"
1253
+ [build] rustc 0 <host> -> std 0 <host>
1254
+ [build] llvm <host>
1255
+ [build] rustc 0 <host> -> rustc 1 <host>
1256
+ [build] rustc 0 <host> -> rustc 1 <host>
1254
1257
" ) ;
1255
1258
}
1259
+
1260
+ impl ConfigBuilder {
1261
+ fn get_steps ( self ) -> String {
1262
+ let config = self . create_config ( ) ;
1263
+
1264
+ let kind = config. cmd . kind ( ) ;
1265
+ let build = Build :: new ( config) ;
1266
+ let builder = Builder :: new ( & build) ;
1267
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( kind) , & builder. paths ) ;
1268
+ render_steps ( & builder. cache . into_executed_steps ( ) )
1269
+ }
1270
+ }
1256
1271
}
1257
1272
1258
1273
/// Renders the executed bootstrap steps for usage in snapshot tests with insta.
@@ -1276,19 +1291,14 @@ fn render_steps(steps: &[(Box<dyn Any>, Box<dyn Any>)]) -> String {
1276
1291
"[build] {} -> std {} <{}>" ,
1277
1292
render_compiler( std. compiler) ,
1278
1293
std. compiler. stage,
1279
- std. target
1294
+ normalize_target ( std. target)
1280
1295
) )
1281
1296
} else if let Some ( ( llvm, output) ) = downcast_step :: < llvm:: Llvm > ( step, output) {
1282
- Some ( format ! ( "[build] llvm <{}>" , llvm. target) )
1297
+ Some ( format ! ( "[build] llvm <{}>" , normalize_target ( llvm. target) ) )
1283
1298
} else {
1284
1299
None
1285
1300
}
1286
1301
} )
1287
- . map ( |line| {
1288
- line. replace ( TEST_TRIPLE_1 , "target1" )
1289
- . replace ( TEST_TRIPLE_2 , "target2" )
1290
- . replace ( TEST_TRIPLE_3 , "target3" )
1291
- } )
1292
1302
. collect :: < Vec < _ > > ( )
1293
1303
. join ( "\n " )
1294
1304
}
@@ -1306,6 +1316,10 @@ fn downcast_step<'a, S: Step>(
1306
1316
Some ( ( step, output) )
1307
1317
}
1308
1318
1319
+ fn normalize_target ( target : TargetSelection ) -> String {
1320
+ target. to_string ( ) . replace ( & get_host_target ( ) . to_string ( ) , "host" )
1321
+ }
1322
+
1309
1323
fn render_compiler ( compiler : Compiler ) -> String {
1310
- format ! ( "rustc {} <{}>" , compiler. stage, compiler. host)
1324
+ format ! ( "rustc {} <{}>" , compiler. stage, normalize_target ( compiler. host) )
1311
1325
}
0 commit comments