@@ -8,6 +8,7 @@ use super::*;
88use crate :: Flags ;
99use crate :: core:: build_steps:: doc:: DocumentationFormat ;
1010use crate :: core:: config:: Config ;
11+ use crate :: utils:: cache:: ExecutedStep ;
1112use crate :: utils:: tests:: git:: { GitCtx , git_test} ;
1213
1314static TEST_TRIPLE_1 : & str = "i686-unknown-haiku" ;
@@ -1258,31 +1259,24 @@ mod staging {
12581259/// Renders the executed bootstrap steps for usage in snapshot tests with insta.
12591260/// Only renders certain important steps.
12601261/// 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 {
12621263 steps
12631264 . 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) ) ;
12851275 }
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)
12861280 } )
12871281 . map ( |line| {
12881282 line. replace ( TEST_TRIPLE_1 , "target1" )
@@ -1293,19 +1287,6 @@ fn render_steps(steps: &[(Box<dyn Any>, Box<dyn Any>)]) -> String {
12931287 . join ( "\n " )
12941288}
12951289
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-
13091290fn render_compiler ( compiler : Compiler ) -> String {
13101291 format ! ( "rustc {} <{}>" , compiler. stage, compiler. host)
13111292}
0 commit comments