Fix `do` not exiting with error when called commands exited with error.
This should fix the CI showing succes when some tests actually failed.
This commit is contained in:
parent
91a5177ea2
commit
626a185f3a
|
@ -25,6 +25,8 @@ fn main() {
|
|||
"help" | "--help" => help(args),
|
||||
_ => fatal(f!("unknown task {task:?}, `{} help` to list tasks", do_cmd())),
|
||||
}
|
||||
|
||||
util::exit_checked();
|
||||
}
|
||||
|
||||
// do install [-a, --accept]
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::format_args as f;
|
|||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{self, Command, Stdio};
|
||||
use std::sync::atomic::*;
|
||||
|
||||
// Command line to run `do`
|
||||
pub fn do_cmd() -> String {
|
||||
|
@ -70,6 +71,7 @@ fn cmd_impl(mut cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&
|
|||
fatal(msg);
|
||||
} else {
|
||||
error(msg);
|
||||
set_exit_with_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +81,7 @@ fn cmd_impl(mut cmd: &str, default_args: &[&str], user_args: &[&str], envs: &[(&
|
|||
fatal(msg)
|
||||
} else {
|
||||
error(msg);
|
||||
set_exit_with_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -445,3 +448,17 @@ pub fn git_modified() -> Vec<PathBuf> {
|
|||
pub fn print_git_diff(file: &std::path::Path) {
|
||||
Command::new("git").arg("diff").arg(file).status().unwrap();
|
||||
}
|
||||
|
||||
static CMD_ERROR: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub fn set_exit_with_error() {
|
||||
CMD_ERROR.store(true, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn exit_checked() {
|
||||
if CMD_ERROR.load(Ordering::Relaxed) {
|
||||
std::process::exit(-1);
|
||||
} else {
|
||||
std::process::exit(0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue