@@ -248,7 +248,7 @@ impl<'test> TestCx<'test> {
248248    } 
249249
250250    fn  run_cfail_test ( & self )  { 
251-         let  proc_res = self . compile_test ( ) ; 
251+         let  proc_res = self . compile_test ( & [ ] ) ; 
252252        self . check_if_test_should_compile ( & proc_res) ; 
253253        self . check_no_compiler_crash ( & proc_res) ; 
254254
@@ -267,7 +267,7 @@ impl<'test> TestCx<'test> {
267267    } 
268268
269269    fn  run_rfail_test ( & self )  { 
270-         let  proc_res = self . compile_test ( ) ; 
270+         let  proc_res = self . compile_test ( & [ ] ) ; 
271271
272272        if  !proc_res. status . success ( )  { 
273273            self . fatal_proc_rec ( "compilation failed!" ,  & proc_res) ; 
@@ -309,7 +309,7 @@ impl<'test> TestCx<'test> {
309309    } 
310310
311311    fn  run_rpass_test ( & self )  { 
312-         let  proc_res = self . compile_test ( ) ; 
312+         let  proc_res = self . compile_test ( & [ ] ) ; 
313313
314314        if  !proc_res. status . success ( )  { 
315315            self . fatal_proc_rec ( "compilation failed!" ,  & proc_res) ; 
@@ -336,7 +336,7 @@ impl<'test> TestCx<'test> {
336336            return  self . run_rpass_test ( ) ; 
337337        } 
338338
339-         let  mut  proc_res = self . compile_test ( ) ; 
339+         let  mut  proc_res = self . compile_test ( & [ ] ) ; 
340340
341341        if  !proc_res. status . success ( )  { 
342342            self . fatal_proc_rec ( "compilation failed!" ,  & proc_res) ; 
@@ -578,7 +578,7 @@ impl<'test> TestCx<'test> {
578578        let  mut  cmds = commands. join ( "\n " ) ; 
579579
580580        // compile test file (it should have 'compile-flags:-g' in the header) 
581-         let  compiler_run_result = self . compile_test ( ) ; 
581+         let  compiler_run_result = self . compile_test ( & [ ] ) ; 
582582        if  !compiler_run_result. status . success ( )  { 
583583            self . fatal_proc_rec ( "compilation failed!" ,  & compiler_run_result) ; 
584584        } 
@@ -835,7 +835,7 @@ impl<'test> TestCx<'test> {
835835
836836    fn  run_debuginfo_lldb_test_no_opt ( & self )  { 
837837        // compile test file (it should have 'compile-flags:-g' in the header) 
838-         let  compile_result = self . compile_test ( ) ; 
838+         let  compile_result = self . compile_test ( & [ ] ) ; 
839839        if  !compile_result. status . success ( )  { 
840840            self . fatal_proc_rec ( "compilation failed!" ,  & compile_result) ; 
841841        } 
@@ -1272,12 +1272,15 @@ impl<'test> TestCx<'test> {
12721272        } 
12731273    } 
12741274
1275-     fn  compile_test ( & self )  -> ProcRes  { 
1275+     fn  compile_test ( & self ,   extra_args :   & [ & ' static   str ] )  -> ProcRes  { 
12761276        let  mut  rustc = self . make_compile_args ( 
12771277            & self . testpaths . file , 
12781278            TargetLocation :: ThisFile ( self . make_exe_name ( ) ) , 
12791279        ) ; 
12801280
1281+         if  !extra_args. is_empty ( )  { 
1282+             rustc. args ( extra_args) ; 
1283+         } 
12811284        rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ; 
12821285
12831286        match  self . config . mode  { 
@@ -1629,8 +1632,11 @@ impl<'test> TestCx<'test> {
16291632                . iter ( ) 
16301633                . any ( |s| s. starts_with ( "--error-format" ) ) 
16311634            { 
1632-                 rustc. args ( & [ "--error-format" ,  "json" ] ) ; 
1633-             } , 
1635+                 // In case no "--error-format" has been given in the test, we'll compile 
1636+                 // a first time to get the compiler's output then compile with 
1637+                 // "--error-format json" to check if all expected errors are actually there 
1638+                 // and that no new one appeared. 
1639+             } 
16341640            MirOpt  => { 
16351641                rustc. args ( & [ 
16361642                    "-Zdump-mir=all" , 
@@ -2109,7 +2115,7 @@ impl<'test> TestCx<'test> {
21092115    fn  run_codegen_units_test ( & self )  { 
21102116        assert ! ( self . revision. is_none( ) ,  "revisions not relevant here" ) ; 
21112117
2112-         let  proc_res = self . compile_test ( ) ; 
2118+         let  proc_res = self . compile_test ( & [ ] ) ; 
21132119
21142120        if  !proc_res. status . success ( )  { 
21152121            self . fatal_proc_rec ( "compilation failed!" ,  & proc_res) ; 
@@ -2493,7 +2499,7 @@ impl<'test> TestCx<'test> {
24932499            . iter ( ) 
24942500            . any ( |s| s. contains ( "--error-format" ) ) ; 
24952501
2496-         let  proc_res = self . compile_test ( ) ; 
2502+         let  proc_res = self . compile_test ( & [ ] ) ; 
24972503        self . check_if_test_should_compile ( & proc_res) ; 
24982504
24992505        let  expected_stderr_path = self . expected_output_path ( UI_STDERR ) ; 
@@ -2505,13 +2511,8 @@ impl<'test> TestCx<'test> {
25052511        let  normalized_stdout =
25062512            self . normalize_output ( & proc_res. stdout ,  & self . props . normalize_stdout ) ; 
25072513
2508-         let  stderr = if  explicit { 
2509-             proc_res. stderr . clone ( ) 
2510-         }  else  { 
2511-             json:: extract_rendered ( & proc_res. stderr ,  & proc_res) 
2512-         } ; 
2513- 
2514-         let  normalized_stderr = self . normalize_output ( & stderr,  & self . props . normalize_stderr ) ; 
2514+         let  normalized_stderr = self . normalize_output ( & proc_res. stderr , 
2515+                                                       & self . props . normalize_stderr ) ; 
25152516
25162517        let  mut  errors = 0 ; 
25172518        errors += self . compare_output ( "stdout" ,  & normalized_stdout,  & expected_stdout) ; 
@@ -2544,6 +2545,7 @@ impl<'test> TestCx<'test> {
25442545            } 
25452546        } 
25462547        if  !explicit { 
2548+             let  proc_res = self . compile_test ( & [ "--error-format" ,  "json" ] ) ; 
25472549            if  !expected_errors. is_empty ( )  || !proc_res. status . success ( )  { 
25482550                // "// error-pattern" comments 
25492551                self . check_expected_errors ( expected_errors,  & proc_res) ; 
@@ -2555,7 +2557,7 @@ impl<'test> TestCx<'test> {
25552557    } 
25562558
25572559    fn  run_mir_opt_test ( & self )  { 
2558-         let  proc_res = self . compile_test ( ) ; 
2560+         let  proc_res = self . compile_test ( & [ ] ) ; 
25592561
25602562        if  !proc_res. status . success ( )  { 
25612563            self . fatal_proc_rec ( "compilation failed!" ,  & proc_res) ; 
0 commit comments