Skip to content

Commit ca20989

Browse files
committed
Improve the Debug representation of BootstrapCommand
Avoid printing useless information in the `Debug` output.
1 parent 5775c18 commit ca20989

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::Build;
22
use build_helper::drop_bomb::DropBomb;
33
use std::ffi::OsStr;
4+
use std::fmt::{Debug, Formatter};
45
use std::path::Path;
56
use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio};
67

@@ -54,7 +55,6 @@ impl OutputMode {
5455
///
5556
/// [allow_failure]: BootstrapCommand::allow_failure
5657
/// [delay_failure]: BootstrapCommand::delay_failure
57-
#[derive(Debug)]
5858
pub struct BootstrapCommand {
5959
command: Command,
6060
pub failure_behavior: BehaviorOnFailure,
@@ -147,6 +147,7 @@ impl BootstrapCommand {
147147
}
148148

149149
/// Run the command, returning its output.
150+
#[track_caller]
150151
pub fn run(&mut self, builder: &Build) -> CommandOutput {
151152
builder.run(self)
152153
}
@@ -172,6 +173,17 @@ impl BootstrapCommand {
172173
}
173174
}
174175

176+
impl Debug for BootstrapCommand {
177+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
178+
write!(f, "{:?}", self.command)?;
179+
write!(
180+
f,
181+
" (failure_mode={:?}, stdout_mode={:?}, stderr_mode={:?})",
182+
self.failure_behavior, self.stdout, self.stderr
183+
)
184+
}
185+
}
186+
175187
impl From<Command> for BootstrapCommand {
176188
#[track_caller]
177189
fn from(command: Command) -> Self {

0 commit comments

Comments
 (0)