Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide failed command unless in verbose mode #93492

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ impl Build {
return;
}
self.verbose(&format!("running: {:?}", cmd));
run(cmd)
run(cmd, self.is_verbose())
}

/// Runs a command, printing out nice contextual information if it fails.
Expand All @@ -871,7 +871,7 @@ impl Build {
return true;
}
self.verbose(&format!("running: {:?}", cmd));
try_run(cmd)
try_run(cmd, self.is_verbose())
}

/// Runs a command, printing out nice contextual information if it fails.
Expand Down
8 changes: 4 additions & 4 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ pub fn restore_library_path() {
}
}

pub fn run(cmd: &mut Command) {
if !try_run(cmd) {
pub fn run(cmd: &mut Command, print_cmd_on_fail: bool) {
if !try_run(cmd, print_cmd_on_fail) {
std::process::exit(1);
}
}

pub fn try_run(cmd: &mut Command) -> bool {
pub fn try_run(cmd: &mut Command, print_cmd_on_fail: bool) -> bool {
let status = match cmd.status() {
Ok(status) => status,
Err(e) => fail(&format!("failed to execute command: {:?}\nerror: {}", cmd, e)),
};
if !status.success() {
if !status.success() && print_cmd_on_fail {
println!(
"\n\ncommand did not execute successfully: {:?}\n\
expected success, got: {}\n\n",
Expand Down