mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
bootstrap: Optionally print a backtrace if a command fails
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//! relevant to command execution in the bootstrap process. This includes settings such as
|
||||
//! dry-run mode, verbosity level, and failure behavior.
|
||||
|
||||
use std::backtrace::{Backtrace, BacktraceStatus};
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
@@ -930,6 +931,16 @@ enum FailureReason {
|
||||
if stderr.captures() {
|
||||
writeln!(error_message, "\n--- STDERR vvv\n{}", output.stderr().trim()).unwrap();
|
||||
}
|
||||
let backtrace = if exec_ctx.verbosity > 1 {
|
||||
Backtrace::force_capture()
|
||||
} else if matches!(command.failure_behavior, BehaviorOnFailure::Ignore) {
|
||||
Backtrace::disabled()
|
||||
} else {
|
||||
Backtrace::capture()
|
||||
};
|
||||
if matches!(backtrace.status(), BacktraceStatus::Captured) {
|
||||
writeln!(error_message, "\n--- BACKTRACE vvv\n{backtrace}").unwrap();
|
||||
}
|
||||
|
||||
match command.failure_behavior {
|
||||
BehaviorOnFailure::DelayFail => {
|
||||
|
||||
Reference in New Issue
Block a user