@@ -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,15 +1272,12 @@ impl<'test> TestCx<'test> {
1272
1272
}
1273
1273
}
1274
1274
1275
- fn compile_test ( & self , extra_args : & [ & ' static str ] ) -> ProcRes {
1275
+ fn compile_test ( & self ) -> 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
- }
1284
1281
rustc. arg ( "-L" ) . arg ( & self . aux_output_dir_name ( ) ) ;
1285
1282
1286
1283
match self . config . mode {
@@ -1628,14 +1625,13 @@ impl<'test> TestCx<'test> {
1628
1625
}
1629
1626
}
1630
1627
Ui => {
1631
- // In case no "--error-format" has been given in the test, we'll compile
1632
- // a first time to get the compiler's output then compile with
1633
- // "--error-format json" to check if all expected errors are actually there
1634
- // and that no new one appeared.
1628
+ if !self . props . compile_flags . iter ( ) . any ( |s| s. starts_with ( "--error-format" ) ) {
1629
+ rustc. args ( & [ "--error-format" , "json" ] ) ;
1630
+ }
1635
1631
if !self . props . disable_ui_testing_normalization {
1636
1632
rustc. arg ( "-Zui-testing" ) ;
1637
1633
}
1638
- }
1634
+ } ,
1639
1635
MirOpt => {
1640
1636
rustc. args ( & [
1641
1637
"-Zdump-mir=all" ,
@@ -2114,7 +2110,7 @@ impl<'test> TestCx<'test> {
2114
2110
fn run_codegen_units_test ( & self ) {
2115
2111
assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
2116
2112
2117
- let proc_res = self . compile_test ( & [ ] ) ;
2113
+ let proc_res = self . compile_test ( ) ;
2118
2114
2119
2115
if !proc_res. status . success ( ) {
2120
2116
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
@@ -2498,7 +2494,7 @@ impl<'test> TestCx<'test> {
2498
2494
. iter ( )
2499
2495
. any ( |s| s. contains ( "--error-format" ) ) ;
2500
2496
2501
- let proc_res = self . compile_test ( & [ ] ) ;
2497
+ let proc_res = self . compile_test ( ) ;
2502
2498
self . check_if_test_should_compile ( & proc_res) ;
2503
2499
2504
2500
let expected_stderr_path = self . expected_output_path ( UI_STDERR ) ;
@@ -2510,8 +2506,13 @@ impl<'test> TestCx<'test> {
2510
2506
let normalized_stdout =
2511
2507
self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ;
2512
2508
2513
- let normalized_stderr = self . normalize_output ( & proc_res. stderr ,
2514
- & self . props . normalize_stderr ) ;
2509
+ let stderr = if explicit {
2510
+ proc_res. stderr . clone ( )
2511
+ } else {
2512
+ json:: extract_rendered ( & proc_res. stderr , & proc_res)
2513
+ } ;
2514
+
2515
+ let normalized_stderr = self . normalize_output ( & stderr, & self . props . normalize_stderr ) ;
2515
2516
2516
2517
let mut errors = 0 ;
2517
2518
errors += self . compare_output ( "stdout" , & normalized_stdout, & expected_stdout) ;
@@ -2544,7 +2545,6 @@ impl<'test> TestCx<'test> {
2544
2545
}
2545
2546
}
2546
2547
if !explicit {
2547
- let proc_res = self . compile_test ( & [ "--error-format" , "json" ] ) ;
2548
2548
if !expected_errors. is_empty ( ) || !proc_res. status . success ( ) {
2549
2549
// "// error-pattern" comments
2550
2550
self . check_expected_errors ( expected_errors, & proc_res) ;
@@ -2556,7 +2556,7 @@ impl<'test> TestCx<'test> {
2556
2556
}
2557
2557
2558
2558
fn run_mir_opt_test ( & self ) {
2559
- let proc_res = self . compile_test ( & [ ] ) ;
2559
+ let proc_res = self . compile_test ( ) ;
2560
2560
2561
2561
if !proc_res. status . success ( ) {
2562
2562
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
0 commit comments