@@ -1012,8 +1012,7 @@ actual:\n\
10121012
10131013 // Parse the JSON output from the compiler and extract out the messages.
10141014 let actual_errors = json:: parse_output ( & file_name, & proc_res. stderr , & proc_res) ;
1015- let mut unexpected = 0 ;
1016- let mut not_found = 0 ;
1015+ let mut unexpected = Vec :: new ( ) ;
10171016 let mut found = vec ! [ false ; expected_errors. len( ) ] ;
10181017 for actual_error in & actual_errors {
10191018 let opt_index =
@@ -1045,12 +1044,13 @@ actual:\n\
10451044 . map_or( String :: from( "message" ) ,
10461045 |k| k. to_string( ) ) ,
10471046 actual_error. msg) ) ;
1048- unexpected += 1 ;
1047+ unexpected. push ( actual_error . clone ( ) ) ;
10491048 }
10501049 }
10511050 }
10521051 }
10531052
1053+ let mut not_found = Vec :: new ( ) ;
10541054 // anything not yet found is a problem
10551055 for ( index, expected_error) in expected_errors. iter ( ) . enumerate ( ) {
10561056 if !found[ index] {
@@ -1062,18 +1062,22 @@ actual:\n\
10621062 . map_or( "message" . into( ) ,
10631063 |k| k. to_string( ) ) ,
10641064 expected_error. msg) ) ;
1065- not_found += 1 ;
1065+ not_found. push ( expected_error . clone ( ) ) ;
10661066 }
10671067 }
10681068
1069- if unexpected > 0 || not_found > 0 {
1069+ if unexpected. len ( ) > 0 || not_found. len ( ) > 0 {
10701070 self . error (
10711071 & format ! ( "{} unexpected errors found, {} expected errors not found" ,
1072- unexpected, not_found) ) ;
1072+ unexpected. len ( ) , not_found. len ( ) ) ) ;
10731073 print ! ( "status: {}\n command: {}\n " ,
10741074 proc_res. status, proc_res. cmdline) ;
1075- println ! ( "actual errors (from JSON output): {:#?}\n " , actual_errors) ;
1076- println ! ( "expected errors (from test file): {:#?}\n " , expected_errors) ;
1075+ if unexpected. len ( ) > 0 {
1076+ println ! ( "unexpected errors (from JSON output): {:#?}\n " , unexpected) ;
1077+ }
1078+ if not_found. len ( ) > 0 {
1079+ println ! ( "not found errors (from test file): {:#?}\n " , not_found) ;
1080+ }
10771081 panic ! ( ) ;
10781082 }
10791083 }
0 commit comments