Skip to content

Commit

Permalink
Rollup merge of rust-lang#128874 - Kobzol:cmd-verbose-logging, r=onur…
Browse files Browse the repository at this point in the history
…-ozkan

Disable verbose bootstrap command failure logging by default

One of my recent bootstrap command refactoring PRs enabled verbose logging of command failures by default. While this is great for debugging bootstrap, in many situations it's just too verbose and prevents the user from seeing the actual printed stdout/stderr, which usually contains much more useful information.

This PR reverts that logic, and only prints a detailed error when `-v` is passed to bootstrap.

r? `@onur-ozkan`
  • Loading branch information
matthiaskrgr authored Aug 9, 2024
2 parents 024acdd + a380d5e commit 6230296
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,8 @@ impl Build {
}

/// Execute a command and return its output.
/// This method should be used for all command executions in bootstrap.
/// Note: Ideally, you should use one of the BootstrapCommand::run* functions to
/// execute commands. They internally call this method.
#[track_caller]
fn run(
&self,
Expand Down Expand Up @@ -1057,20 +1058,28 @@ Executed at: {executed_at}"#,
CommandOutput::did_not_start(stdout, stderr)
}
};

let fail = |message: &str| {
if self.is_verbose() {
println!("{message}");
} else {
println!("Command has failed. Rerun with -v to see more details.");
}
exit!(1);
};

if !output.is_success() {
match command.failure_behavior {
BehaviorOnFailure::DelayFail => {
if self.fail_fast {
println!("{message}");
exit!(1);
fail(&message);
}

let mut failures = self.delayed_failures.borrow_mut();
failures.push(message);
}
BehaviorOnFailure::Exit => {
println!("{message}");
exit!(1);
fail(&message);
}
BehaviorOnFailure::Ignore => {
// If failures are allowed, either the error has been printed already
Expand Down

0 comments on commit 6230296

Please sign in to comment.