@@ -90,7 +90,7 @@ mod job {
90
90
pub use crate :: builder:: PathSet ;
91
91
use crate :: cache:: { Interned , INTERNER } ;
92
92
pub use crate :: config:: Config ;
93
- use crate :: exec:: { BootstrapCommand , OutputOnFailure } ;
93
+ use crate :: exec:: { BehaviorOnFailure , BootstrapCommand , OutputOnFailure } ;
94
94
pub use crate :: flags:: Subcommand ;
95
95
use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
96
96
@@ -976,22 +976,26 @@ impl Build {
976
976
/// Runs a command, printing out nice contextual information if it fails.
977
977
fn run_quiet ( & self , cmd : & mut Command ) {
978
978
let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
979
- // TODO: fail bootstrap immediately if this command fails
980
- self . run_cmd ( cmd. output_on_failure ( OutputOnFailure :: Verbose ) ) ;
979
+ self . run_cmd (
980
+ cmd. failure_output ( OutputOnFailure :: Verbose ) . failure_behavior ( BehaviorOnFailure :: Exit ) ,
981
+ ) ;
981
982
}
982
983
983
984
/// Runs a command, printing out nice contextual information if it fails.
984
985
/// Exits if the command failed to execute at all, otherwise returns its
985
986
/// `status.success()`.
986
987
fn run_quiet_delaying_failure ( & self , cmd : & mut Command ) -> bool {
987
988
let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
988
- self . run_cmd ( cmd. output_on_failure ( OutputOnFailure :: Verbose ) . delay_failure ( ) )
989
+ self . run_cmd (
990
+ cmd. failure_output ( OutputOnFailure :: Verbose )
991
+ . failure_behavior ( BehaviorOnFailure :: DelayFail ) ,
992
+ )
989
993
}
990
994
991
995
/// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
992
996
pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
993
997
let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
994
- self . run_cmd ( cmd. delay_failure ( ) )
998
+ self . run_cmd ( cmd. failure_behavior ( BehaviorOnFailure :: DelayFail ) )
995
999
}
996
1000
997
1001
/// A centralized function for running commands that do not return output.
@@ -1004,7 +1008,7 @@ impl Build {
1004
1008
Err ( e) => fail ( & format ! ( "failed to execute command: {:?}\n error: {}" , command, e) ) ,
1005
1009
} ;
1006
1010
let result = if !output. status . success ( ) {
1007
- let output_on_failure = match command. output_on_failure {
1011
+ let output_on_failure = match command. failure_output {
1008
1012
Some ( output) => Some ( output) ,
1009
1013
None if self . is_verbose ( ) => Some ( OutputOnFailure :: Succint ) ,
1010
1014
None => None ,
@@ -1040,10 +1044,16 @@ impl Build {
1040
1044
match result {
1041
1045
Ok ( _) => true ,
1042
1046
Err ( _) => {
1043
- if command. delay_failure {
1044
- let mut failures = self . delayed_failures . borrow_mut ( ) ;
1045
- failures. push ( format ! ( "{command:?}" ) ) ;
1046
- return false ;
1047
+ if let Some ( failure_behavior) = command. failure_behavior {
1048
+ match failure_behavior {
1049
+ BehaviorOnFailure :: DelayFail => {
1050
+ let mut failures = self . delayed_failures . borrow_mut ( ) ;
1051
+ failures. push ( format ! ( "{command:?}" ) ) ;
1052
+ }
1053
+ BehaviorOnFailure :: Exit => {
1054
+ exit ! ( 1 ) ;
1055
+ }
1056
+ }
1047
1057
}
1048
1058
if self . fail_fast {
1049
1059
exit ! ( 1 ) ;
0 commit comments