diff options
| author | Jakub Beránek <jakub.beranek@vsb.cz> | 2024-07-04 20:32:03 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2024-07-12 20:15:19 +0200 |
| commit | fdf1477221ae7a504d6616b001f3edb6c4c50c6a (patch) | |
| tree | 605e2de1087205d597280c7a61565aedc44a2179 | |
| parent | 542344f5bb32a8593b4d775d351d3f4fc8e55fda (diff) | |
| download | rust-fdf1477221ae7a504d6616b001f3edb6c4c50c6a.tar.gz rust-fdf1477221ae7a504d6616b001f3edb6c4c50c6a.zip | |
Improve the `Debug` representation of `BootstrapCommand`
Avoid printing useless information in the `Debug` output.
| -rw-r--r-- | src/bootstrap/src/utils/exec.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index 38fc0cf70b5..c8457f2d0c9 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -1,6 +1,7 @@ use crate::Build; use build_helper::drop_bomb::DropBomb; use std::ffi::OsStr; +use std::fmt::{Debug, Formatter}; use std::path::Path; use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio}; @@ -54,7 +55,6 @@ impl OutputMode { /// /// [allow_failure]: BootstrapCommand::allow_failure /// [delay_failure]: BootstrapCommand::delay_failure -#[derive(Debug)] pub struct BootstrapCommand { command: Command, pub failure_behavior: BehaviorOnFailure, @@ -147,6 +147,7 @@ impl BootstrapCommand { } /// Run the command, returning its output. + #[track_caller] pub fn run(&mut self, builder: &Build) -> CommandOutput { builder.run(self) } @@ -172,6 +173,17 @@ impl BootstrapCommand { } } +impl Debug for BootstrapCommand { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.command)?; + write!( + f, + " (failure_mode={:?}, stdout_mode={:?}, stderr_mode={:?})", + self.failure_behavior, self.stdout, self.stderr + ) + } +} + impl From<Command> for BootstrapCommand { #[track_caller] fn from(command: Command) -> Self { |
