File tree 3 files changed +26
-7
lines changed
src/tools/compiletest/src
3 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -318,10 +318,29 @@ impl<'test> TestCx<'test> {
318
318
}
319
319
}
320
320
321
- fn check_if_test_should_compile ( & self , proc_res : & ProcRes , pm : Option < PassMode > ) {
322
- if self . should_compile_successfully ( pm) {
321
+ fn check_if_test_should_compile (
322
+ & self ,
323
+ fail_mode : Option < FailMode > ,
324
+ pass_mode : Option < PassMode > ,
325
+ proc_res : & ProcRes ,
326
+ ) {
327
+ if self . should_compile_successfully ( pass_mode) {
323
328
if !proc_res. status . success ( ) {
324
- self . fatal_proc_rec ( "test compilation failed although it shouldn't!" , proc_res) ;
329
+ match ( fail_mode, pass_mode) {
330
+ ( Some ( FailMode :: Build ) , Some ( PassMode :: Check ) ) => {
331
+ // A `build-fail` test needs to `check-pass`.
332
+ self . fatal_proc_rec (
333
+ "`build-fail` test is required to pass check build, but check build failed" ,
334
+ proc_res,
335
+ ) ;
336
+ }
337
+ _ => {
338
+ self . fatal_proc_rec (
339
+ "test compilation failed although it shouldn't!" ,
340
+ proc_res,
341
+ ) ;
342
+ }
343
+ }
325
344
}
326
345
} else {
327
346
if proc_res. status . success ( ) {
Original file line number Diff line number Diff line change 1
- use super :: { TestCx , WillExecute } ;
1
+ use super :: { FailMode , TestCx , WillExecute } ;
2
2
use crate :: errors;
3
3
4
4
impl TestCx < ' _ > {
@@ -96,7 +96,7 @@ impl TestCx<'_> {
96
96
fn run_cfail_test ( & self ) {
97
97
let pm = self . pass_mode ( ) ;
98
98
let proc_res = self . compile_test ( WillExecute :: No , self . should_emit_metadata ( pm) ) ;
99
- self . check_if_test_should_compile ( & proc_res , pm) ;
99
+ self . check_if_test_should_compile ( Some ( FailMode :: Build ) , pm, & proc_res ) ;
100
100
self . check_no_compiler_crash ( & proc_res, self . props . should_ice ) ;
101
101
102
102
let output_to_check = self . get_output ( & proc_res) ;
Original file line number Diff line number Diff line change @@ -18,14 +18,14 @@ impl TestCx<'_> {
18
18
let pm = Some ( PassMode :: Check ) ;
19
19
let proc_res =
20
20
self . compile_test_general ( WillExecute :: No , Emit :: Metadata , pm, Vec :: new ( ) ) ;
21
- self . check_if_test_should_compile ( & proc_res , pm) ;
21
+ self . check_if_test_should_compile ( self . props . fail_mode , pm, & proc_res ) ;
22
22
}
23
23
24
24
let pm = self . pass_mode ( ) ;
25
25
let should_run = self . should_run ( pm) ;
26
26
let emit_metadata = self . should_emit_metadata ( pm) ;
27
27
let proc_res = self . compile_test ( should_run, emit_metadata) ;
28
- self . check_if_test_should_compile ( & proc_res , pm) ;
28
+ self . check_if_test_should_compile ( self . props . fail_mode , pm, & proc_res ) ;
29
29
if matches ! ( proc_res. truncated, Truncated :: Yes )
30
30
&& !self . props . dont_check_compiler_stdout
31
31
&& !self . props . dont_check_compiler_stderr
You can’t perform that action at this time.
0 commit comments