@@ -1012,8 +1012,7 @@ actual:\n\
1012
1012
1013
1013
// Parse the JSON output from the compiler and extract out the messages.
1014
1014
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 ( ) ;
1017
1016
let mut found = vec ! [ false ; expected_errors. len( ) ] ;
1018
1017
for actual_error in & actual_errors {
1019
1018
let opt_index =
@@ -1045,12 +1044,13 @@ actual:\n\
1045
1044
. map_or( String :: from( "message" ) ,
1046
1045
|k| k. to_string( ) ) ,
1047
1046
actual_error. msg) ) ;
1048
- unexpected += 1 ;
1047
+ unexpected. push ( actual_error . clone ( ) ) ;
1049
1048
}
1050
1049
}
1051
1050
}
1052
1051
}
1053
1052
1053
+ let mut not_found = Vec :: new ( ) ;
1054
1054
// anything not yet found is a problem
1055
1055
for ( index, expected_error) in expected_errors. iter ( ) . enumerate ( ) {
1056
1056
if !found[ index] {
@@ -1062,18 +1062,22 @@ actual:\n\
1062
1062
. map_or( "message" . into( ) ,
1063
1063
|k| k. to_string( ) ) ,
1064
1064
expected_error. msg) ) ;
1065
- not_found += 1 ;
1065
+ not_found. push ( expected_error . clone ( ) ) ;
1066
1066
}
1067
1067
}
1068
1068
1069
- if unexpected > 0 || not_found > 0 {
1069
+ if unexpected. len ( ) > 0 || not_found. len ( ) > 0 {
1070
1070
self . error (
1071
1071
& format ! ( "{} unexpected errors found, {} expected errors not found" ,
1072
- unexpected, not_found) ) ;
1072
+ unexpected. len ( ) , not_found. len ( ) ) ) ;
1073
1073
print ! ( "status: {}\n command: {}\n " ,
1074
1074
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
+ }
1077
1081
panic ! ( ) ;
1078
1082
}
1079
1083
}
0 commit comments