@@ -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:: cache:: ExecutedStep ;
11
12
use crate :: utils:: tests:: git:: { GitCtx , git_test} ;
12
13
13
14
static TEST_TRIPLE_1 : & str = "i686-unknown-haiku" ;
@@ -1258,31 +1259,24 @@ mod staging {
1258
1259
/// Renders the executed bootstrap steps for usage in snapshot tests with insta.
1259
1260
/// Only renders certain important steps.
1260
1261
/// Each value in `steps` should be a tuple of (Step, step output).
1261
- fn render_steps ( steps : & [ ( Box < dyn Any > , Box < dyn Any > ) ] ) -> String {
1262
+ fn render_steps ( steps : & [ ExecutedStep ] ) -> String {
1262
1263
steps
1263
1264
. iter ( )
1264
- . filter_map ( |( step, output) | {
1265
- // FIXME: implement an optional method on Step to produce metadata for test, instead
1266
- // of this downcasting
1267
- if let Some ( ( rustc, output) ) = downcast_step :: < compile:: Rustc > ( step, output) {
1268
- Some ( format ! (
1269
- "[build] {} -> {}" ,
1270
- render_compiler( rustc. build_compiler) ,
1271
- // FIXME: return the correct stage from the `Rustc` step, now it behaves weirdly
1272
- render_compiler( Compiler :: new( rustc. build_compiler. stage + 1 , rustc. target) ) ,
1273
- ) )
1274
- } else if let Some ( ( std, output) ) = downcast_step :: < compile:: Std > ( step, output) {
1275
- Some ( format ! (
1276
- "[build] {} -> std {} <{}>" ,
1277
- render_compiler( std. compiler) ,
1278
- std. compiler. stage,
1279
- std. target
1280
- ) )
1281
- } else if let Some ( ( llvm, output) ) = downcast_step :: < llvm:: Llvm > ( step, output) {
1282
- Some ( format ! ( "[build] llvm <{}>" , llvm. target) )
1283
- } else {
1284
- None
1265
+ . filter_map ( |step| {
1266
+ use std:: fmt:: Write ;
1267
+
1268
+ let Some ( metadata) = & step. metadata else {
1269
+ return None ;
1270
+ } ;
1271
+
1272
+ let mut record = format ! ( "[{}] " , metadata. kind. as_str( ) ) ;
1273
+ if let Some ( compiler) = metadata. built_by {
1274
+ write ! ( record, "{} -> " , render_compiler( compiler) ) ;
1285
1275
}
1276
+ let stage =
1277
+ if let Some ( stage) = metadata. stage { format ! ( "{stage} " ) } else { "" . to_string ( ) } ;
1278
+ write ! ( record, "{} {stage}<{}>" , metadata. name, metadata. target) ;
1279
+ Some ( record)
1286
1280
} )
1287
1281
. map ( |line| {
1288
1282
line. replace ( TEST_TRIPLE_1 , "target1" )
@@ -1293,19 +1287,6 @@ fn render_steps(steps: &[(Box<dyn Any>, Box<dyn Any>)]) -> String {
1293
1287
. join ( "\n " )
1294
1288
}
1295
1289
1296
- fn downcast_step < ' a , S : Step > (
1297
- step : & ' a Box < dyn Any > ,
1298
- output : & ' a Box < dyn Any > ,
1299
- ) -> Option < ( & ' a S , & ' a S :: Output ) > {
1300
- let Some ( step) = step. downcast_ref :: < S > ( ) else {
1301
- return None ;
1302
- } ;
1303
- let Some ( output) = output. downcast_ref :: < S :: Output > ( ) else {
1304
- return None ;
1305
- } ;
1306
- Some ( ( step, output) )
1307
- }
1308
-
1309
1290
fn render_compiler ( compiler : Compiler ) -> String {
1310
1291
format ! ( "rustc {} <{}>" , compiler. stage, compiler. host)
1311
1292
}
0 commit comments