File tree Expand file tree Collapse file tree 3 files changed +26
-7
lines changed
src/tools/compiletest/src Expand file tree Collapse file tree 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> {
318318 }
319319 }
320320
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) {
323328 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+ }
325344 }
326345 } else {
327346 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 } ;
22use crate :: errors;
33
44impl TestCx < ' _ > {
@@ -96,7 +96,7 @@ impl TestCx<'_> {
9696 fn run_cfail_test ( & self ) {
9797 let pm = self . pass_mode ( ) ;
9898 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 ) ;
100100 self . check_no_compiler_crash ( & proc_res, self . props . should_ice ) ;
101101
102102 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<'_> {
1818 let pm = Some ( PassMode :: Check ) ;
1919 let proc_res =
2020 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 ) ;
2222 }
2323
2424 let pm = self . pass_mode ( ) ;
2525 let should_run = self . should_run ( pm) ;
2626 let emit_metadata = self . should_emit_metadata ( pm) ;
2727 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 ) ;
2929 if matches ! ( proc_res. truncated, Truncated :: Yes )
3030 && !self . props . dont_check_compiler_stdout
3131 && !self . props . dont_check_compiler_stderr
You can’t perform that action at this time.
0 commit comments