@@ -359,22 +359,20 @@ impl<'test> TestCx<'test> {
359
359
360
360
fn should_run ( & self , pm : Option < PassMode > ) -> WillExecute {
361
361
let test_should_run = match self . config . mode {
362
- Ui if pm == Some ( PassMode :: Run ) || self . props . fail_mode == Some ( FailMode :: Run ) => {
363
- true
364
- }
362
+ Ui if pm == Some ( PassMode :: Run ) || self . props . fail_mode == Some ( FailMode :: Run ) => true ,
365
363
MirOpt if pm == Some ( PassMode :: Run ) => true ,
366
364
Ui | MirOpt => false ,
367
365
mode => panic ! ( "unimplemented for mode {:?}" , mode) ,
368
366
} ;
367
+ if test_should_run { self . run_if_enabled ( ) } else { WillExecute :: No }
368
+ }
369
+
370
+ fn run_if_enabled ( & self ) -> WillExecute {
369
371
let enabled = self . config . run . unwrap_or_else ( || {
370
372
// Auto-detect whether to run based on the platform.
371
373
!self . config . target . ends_with ( "-fuchsia" )
372
374
} ) ;
373
- match ( test_should_run, enabled) {
374
- ( false , _) => WillExecute :: No ,
375
- ( true , true ) => WillExecute :: Yes ,
376
- ( true , false ) => WillExecute :: Disabled ,
377
- }
375
+ if enabled { WillExecute :: Yes } else { WillExecute :: Disabled }
378
376
}
379
377
380
378
fn should_run_successfully ( & self , pm : Option < PassMode > ) -> bool {
@@ -449,12 +447,17 @@ impl<'test> TestCx<'test> {
449
447
450
448
fn run_rfail_test ( & self ) {
451
449
let pm = self . pass_mode ( ) ;
452
- let proc_res = self . compile_test ( WillExecute :: Yes , self . should_emit_metadata ( pm) ) ;
450
+ let should_run = self . run_if_enabled ( ) ;
451
+ let proc_res = self . compile_test ( should_run, self . should_emit_metadata ( pm) ) ;
453
452
454
453
if !proc_res. status . success ( ) {
455
454
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
456
455
}
457
456
457
+ if let WillExecute :: Disabled = should_run {
458
+ return ;
459
+ }
460
+
458
461
let proc_res = self . exec_compiled_test ( ) ;
459
462
460
463
// The value our Makefile configures valgrind to return on failure
@@ -493,12 +496,17 @@ impl<'test> TestCx<'test> {
493
496
494
497
fn run_rpass_test ( & self ) {
495
498
let emit_metadata = self . should_emit_metadata ( self . pass_mode ( ) ) ;
496
- let proc_res = self . compile_test ( WillExecute :: Yes , emit_metadata) ;
499
+ let should_run = self . run_if_enabled ( ) ;
500
+ let proc_res = self . compile_test ( should_run, emit_metadata) ;
497
501
498
502
if !proc_res. status . success ( ) {
499
503
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
500
504
}
501
505
506
+ if let WillExecute :: Disabled = should_run {
507
+ return ;
508
+ }
509
+
502
510
// FIXME(#41968): Move this check to tidy?
503
511
let expected_errors = errors:: load_errors ( & self . testpaths . file , self . revision ) ;
504
512
assert ! (
@@ -520,12 +528,17 @@ impl<'test> TestCx<'test> {
520
528
return self . run_rpass_test ( ) ;
521
529
}
522
530
523
- let mut proc_res = self . compile_test ( WillExecute :: Yes , EmitMetadata :: No ) ;
531
+ let should_run = self . run_if_enabled ( ) ;
532
+ let mut proc_res = self . compile_test ( should_run, EmitMetadata :: No ) ;
524
533
525
534
if !proc_res. status . success ( ) {
526
535
self . fatal_proc_rec ( "compilation failed!" , & proc_res) ;
527
536
}
528
537
538
+ if let WillExecute :: Disabled = should_run {
539
+ return ;
540
+ }
541
+
529
542
let mut new_config = self . config . clone ( ) ;
530
543
new_config. runtool = new_config. valgrind_path . clone ( ) ;
531
544
let new_cx = TestCx { config : & new_config, ..* self } ;
@@ -742,10 +755,14 @@ impl<'test> TestCx<'test> {
742
755
743
756
fn run_debuginfo_cdb_test_no_opt ( & self ) {
744
757
// compile test file (it should have 'compile-flags:-g' in the header)
745
- let compile_result = self . compile_test ( WillExecute :: Yes , EmitMetadata :: No ) ;
758
+ let should_run = self . run_if_enabled ( ) ;
759
+ let compile_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
746
760
if !compile_result. status . success ( ) {
747
761
self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
748
762
}
763
+ if let WillExecute :: Disabled = should_run {
764
+ return ;
765
+ }
749
766
750
767
let exe_file = self . make_exe_name ( ) ;
751
768
@@ -836,10 +853,14 @@ impl<'test> TestCx<'test> {
836
853
let mut cmds = commands. join ( "\n " ) ;
837
854
838
855
// compile test file (it should have 'compile-flags:-g' in the header)
839
- let compiler_run_result = self . compile_test ( WillExecute :: Yes , EmitMetadata :: No ) ;
856
+ let should_run = self . run_if_enabled ( ) ;
857
+ let compiler_run_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
840
858
if !compiler_run_result. status . success ( ) {
841
859
self . fatal_proc_rec ( "compilation failed!" , & compiler_run_result) ;
842
860
}
861
+ if let WillExecute :: Disabled = should_run {
862
+ return ;
863
+ }
843
864
844
865
let exe_file = self . make_exe_name ( ) ;
845
866
@@ -1054,10 +1075,14 @@ impl<'test> TestCx<'test> {
1054
1075
1055
1076
fn run_debuginfo_lldb_test_no_opt ( & self ) {
1056
1077
// compile test file (it should have 'compile-flags:-g' in the header)
1057
- let compile_result = self . compile_test ( WillExecute :: Yes , EmitMetadata :: No ) ;
1078
+ let should_run = self . run_if_enabled ( ) ;
1079
+ let compile_result = self . compile_test ( should_run, EmitMetadata :: No ) ;
1058
1080
if !compile_result. status . success ( ) {
1059
1081
self . fatal_proc_rec ( "compilation failed!" , & compile_result) ;
1060
1082
}
1083
+ if let WillExecute :: Disabled = should_run {
1084
+ return ;
1085
+ }
1061
1086
1062
1087
let exe_file = self . make_exe_name ( ) ;
1063
1088
@@ -1541,8 +1566,9 @@ impl<'test> TestCx<'test> {
1541
1566
// Only use `make_exe_name` when the test ends up being executed.
1542
1567
let output_file = match will_execute {
1543
1568
WillExecute :: Yes => TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ,
1544
- WillExecute :: No | WillExecute :: Disabled =>
1545
- TargetLocation :: ThisDirectory ( self . output_base_dir ( ) ) ,
1569
+ WillExecute :: No | WillExecute :: Disabled => {
1570
+ TargetLocation :: ThisDirectory ( self . output_base_dir ( ) )
1571
+ }
1546
1572
} ;
1547
1573
1548
1574
let allow_unused = match self . config . mode {
0 commit comments