@@ -248,7 +248,7 @@ impl<'test> TestCx<'test> {
248
248
}
249
249
250
250
fn run_cfail_test ( & self ) {
251
- let proc_res = self . compile_test ( ) ;
251
+ let proc_res = self . compile_test ( & [ ] ) ;
252
252
self . check_if_test_should_compile ( & proc_res) ;
253
253
self . check_no_compiler_crash ( & proc_res) ;
254
254
@@ -267,7 +267,7 @@ impl<'test> TestCx<'test> {
267
267
}
268
268
269
269
fn run_rfail_test ( & self ) {
270
- let proc_res = self . compile_test ( ) ;
270
+ let proc_res = self . compile_test ( & [ ] ) ;
271
271
272
272
if !proc_res. status . success ( ) {
273
273
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -309,7 +309,7 @@ impl<'test> TestCx<'test> {
309
309
}
310
310
311
311
fn run_rpass_test ( & self ) {
312
- let proc_res = self . compile_test ( ) ;
312
+ let proc_res = self . compile_test ( & [ ] ) ;
313
313
314
314
if !proc_res. status . success ( ) {
315
315
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -336,7 +336,7 @@ impl<'test> TestCx<'test> {
336
336
return self . run_rpass_test ( ) ;
337
337
}
338
338
339
- let mut proc_res = self . compile_test ( ) ;
339
+ let mut proc_res = self . compile_test ( & [ ] ) ;
340
340
341
341
if !proc_res. status . success ( ) {
342
342
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -578,7 +578,7 @@ impl<'test> TestCx<'test> {
578
578
let mut cmds = commands. join ( "\n " ) ;
579
579
580
580
// 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 ( & [ ] ) ;
582
582
if !compiler_run_result. status . success ( ) {
583
583
self . fatal_proc_rec ( "compilation failed!" , & compiler_run_result) ;
584
584
}
@@ -835,7 +835,7 @@ impl<'test> TestCx<'test> {
835
835
836
836
fn run_debuginfo_lldb_test_no_opt ( & self ) {
837
837
// 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 ( & [ ] ) ;
839
839
if !compile_result. status . success ( ) {
840
840
self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
841
841
}
@@ -1272,12 +1272,15 @@ impl<'test> TestCx<'test> {
1272
1272
}
1273
1273
}
1274
1274
1275
- fn compile_test ( & self ) -> ProcRes {
1275
+ fn compile_test ( & self , extra_args : & [ & ' static str ] ) -> ProcRes {
1276
1276
let mut rustc = self . make_compile_args (
1277
1277
& self . testpaths . file ,
1278
1278
TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ,
1279
1279
) ;
1280
1280
1281
+ if !extra_args. is_empty ( ) {
1282
+ rustc. args ( extra_args) ;
1283
+ }
1281
1284
rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1282
1285
1283
1286
match self . config . mode {
@@ -1629,8 +1632,11 @@ impl<'test> TestCx<'test> {
1629
1632
. iter ( )
1630
1633
. any ( |s| s. starts_with ( "--error-format" ) )
1631
1634
{
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
+ }
1634
1640
MirOpt => {
1635
1641
rustc. args ( & [
1636
1642
"-Zdump-mir=all" ,
@@ -2109,7 +2115,7 @@ impl<'test> TestCx<'test> {
2109
2115
fn run_codegen_units_test ( & self ) {
2110
2116
assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
2111
2117
2112
- let proc_res = self . compile_test ( ) ;
2118
+ let proc_res = self . compile_test ( & [ ] ) ;
2113
2119
2114
2120
if !proc_res. status . success ( ) {
2115
2121
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -2493,7 +2499,7 @@ impl<'test> TestCx<'test> {
2493
2499
. iter ( )
2494
2500
. any ( |s| s. contains ( "--error-format" ) ) ;
2495
2501
2496
- let proc_res = self . compile_test ( ) ;
2502
+ let proc_res = self . compile_test ( & [ ] ) ;
2497
2503
self . check_if_test_should_compile ( & proc_res) ;
2498
2504
2499
2505
let expected_stderr_path = self . expected_output_path ( UI_STDERR ) ;
@@ -2505,13 +2511,8 @@ impl<'test> TestCx<'test> {
2505
2511
let normalized_stdout =
2506
2512
self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ;
2507
2513
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 ) ;
2515
2516
2516
2517
let mut errors = 0 ;
2517
2518
errors += self . compare_output ( "stdout" , & normalized_stdout, & expected_stdout) ;
@@ -2544,6 +2545,7 @@ impl<'test> TestCx<'test> {
2544
2545
}
2545
2546
}
2546
2547
if !explicit {
2548
+ let proc_res = self . compile_test ( & [ "--error-format" , "json" ] ) ;
2547
2549
if !expected_errors. is_empty ( ) || !proc_res. status . success ( ) {
2548
2550
// "// error-pattern" comments
2549
2551
self . check_expected_errors ( expected_errors, & proc_res) ;
@@ -2555,7 +2557,7 @@ impl<'test> TestCx<'test> {
2555
2557
}
2556
2558
2557
2559
fn run_mir_opt_test ( & self ) {
2558
- let proc_res = self . compile_test ( ) ;
2560
+ let proc_res = self . compile_test ( & [ ] ) ;
2559
2561
2560
2562
if !proc_res. status . success ( ) {
2561
2563
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
0 commit comments