Skip to content

Commit

Permalink
Remove run_quiet_delaying_failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jun 20, 2024
1 parent 949e667 commit e933cfb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2342,11 +2342,11 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
let test_args = builder.config.test_args().join(" ");
cmd.arg("--test-args").arg(test_args);

if builder.config.verbose_tests {
builder.run_delaying_failure(&mut cmd)
} else {
builder.run_quiet_delaying_failure(&mut cmd)
let mut cmd = BootstrapCommand::from(&mut cmd).delay_failure();
if !builder.config.verbose_tests {
cmd = cmd.quiet();
}
builder.run_tracked(cmd).is_success()
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down
10 changes: 1 addition & 9 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ impl Build {
})
}

/// Execute a command and return its output.
fn run_tracked(&self, command: BootstrapCommand<'_>) -> CommandOutput {
if self.config.dry_run() {
return CommandOutput::default();
Expand Down Expand Up @@ -1037,15 +1038,6 @@ impl Build {
))
}

/// Runs a command, printing out nice contextual information if it fails.
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
fn run_quiet_delaying_failure(&self, cmd: &mut Command) -> bool {
self.run_cmd(
BootstrapCommand::from(cmd).delay_failure().output_mode(OutputMode::PrintOnFailure),
)
}

/// A centralized function for running commands that do not return output.
pub(crate) fn run_cmd<'a, C: Into<BootstrapCommand<'a>>>(&self, cmd: C) -> bool {
if self.config.dry_run() {
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ impl<'a> BootstrapCommand<'a> {
Self { failure_behavior: BehaviorOnFailure::Ignore, ..self }
}

/// Do not print the output of the command, unless it fails.
pub fn quiet(self) -> Self {
self.output_mode(OutputMode::PrintOnFailure)
}

pub fn output_mode(self, output_mode: OutputMode) -> Self {
Self { output_mode, ..self }
}
Expand Down

0 comments on commit e933cfb

Please sign in to comment.