@@ -210,6 +210,7 @@ struct TestSuiteData {
210210#[ derive( Hash ,  PartialEq ,  Eq ,  Debug ,  Clone ) ]  
211211struct  Test  { 
212212    name :  String , 
213+     stage :  u8 , 
213214    is_doctest :  bool , 
214215} 
215216
@@ -218,27 +219,24 @@ fn aggregate_tests(metrics: &JsonRoot) -> TestSuiteData {
218219    let  mut  tests = HashMap :: new ( ) ; 
219220    let  test_suites = get_test_suites ( & metrics) ; 
220221    for  suite in  test_suites { 
222+         let  stage = match  suite. metadata  { 
223+             TestSuiteMetadata :: CargoPackage  {  stage,  .. }  => stage, 
224+             TestSuiteMetadata :: Compiletest  {  stage,  .. }  => stage, 
225+         }  as  u8 ; 
221226        for  test in  & suite. tests  { 
222227            // Poor man's detection of doctests based on the "(line XYZ)" suffix 
223228            let  is_doctest = matches ! ( suite. metadata,  TestSuiteMetadata :: CargoPackage  {  .. } ) 
224229                && test. name . contains ( "(line" ) ; 
225-             let  test_entry = Test  {  name :  generate_test_name ( & test. name ,   & suite ) ,  is_doctest } ; 
230+             let  test_entry = Test  {  name :  generate_test_name ( & test. name ) ,  stage ,  is_doctest } ; 
226231            tests. insert ( test_entry,  test. outcome . clone ( ) ) ; 
227232        } 
228233    } 
229234    TestSuiteData  {  tests } 
230235} 
231236
232- /// Normalizes Windows-style path delimiters to Unix-style paths 
233- /// and adds suite metadata to the test name. 
234- fn  generate_test_name ( name :  & str ,  suite :  & TestSuite )  -> String  { 
235-     let  name = name. replace ( '\\' ,  "/" ) ; 
236-     let  stage = match  suite. metadata  { 
237-         TestSuiteMetadata :: CargoPackage  {  stage,  .. }  => stage, 
238-         TestSuiteMetadata :: Compiletest  {  stage,  .. }  => stage, 
239-     } ; 
240- 
241-     format ! ( "{name} (stage {stage})" ) 
237+ /// Normalizes Windows-style path delimiters to Unix-style paths. 
238+ fn  generate_test_name ( name :  & str )  -> String  { 
239+     name. replace ( '\\' ,  "/" ) 
242240} 
243241
244242/// Prints test changes in Markdown format to stdout. 
@@ -321,16 +319,25 @@ fn report_test_diffs(diff: AggregatedTestDiffs) {
321319    // Sort diffs by job group and test name 
322320    grouped_diffs. sort_by ( |( d1,  g1) ,  ( d2,  g2) | g1. cmp ( & g2) . then ( d1. test . name . cmp ( & d2. test . name ) ) ) ; 
323321
322+     // Now group the tests by stage 
323+     let  mut  grouped_by_stage:  BTreeMap < u8 ,  Vec < ( & TestDiff ,  u64 ) > >  = Default :: default ( ) ; 
324+     for  ( diff,  group)  in  grouped_diffs { 
325+         grouped_by_stage. entry ( diff. test . stage ) . or_default ( ) . push ( ( diff,  group) ) 
326+     } 
327+ 
324328    output_details ( 
325329        & format ! ( "Show {} test {}\n " ,  original_diff_count,  pluralize( "diff" ,  original_diff_count) ) , 
326330        || { 
327-             for  ( diff,  job_group)  in  grouped_diffs { 
328-                 println ! ( 
329-                     "- `{}`: {} ({})" , 
330-                     diff. test. name, 
331-                     format_diff( & diff. diff) , 
332-                     format_job_group( job_group) 
333-                 ) ; 
331+             for  ( stage,  diffs)  in  grouped_by_stage { 
332+                 println ! ( "## Stage {stage}" ) ; 
333+                 for  ( diff,  job_group)  in  diffs { 
334+                     println ! ( 
335+                         "- `{}`: {} ({})" , 
336+                         diff. test. name, 
337+                         format_diff( & diff. diff) , 
338+                         format_job_group( job_group) 
339+                     ) ; 
340+                 } 
334341            } 
335342
336343            let  extra_diffs = diffs. len ( ) . saturating_sub ( max_diff_count) ; 
0 commit comments