Remove run_delaying_failure

This commit is contained in:
Jakub Beránek 2024-06-20 11:52:48 +02:00
parent e933cfb13c
commit 0de7b92cc6
3 changed files with 32 additions and 30 deletions

View File

@ -156,7 +156,10 @@ You can skip linkcheck with --skip src/tools/linkchecker"
let _guard =
builder.msg(Kind::Test, compiler.stage, "Linkcheck", bootstrap_host, bootstrap_host);
let _time = helpers::timeit(builder);
builder.run_delaying_failure(linkchecker.arg(builder.out.join(host.triple).join("doc")));
builder.run_tracked(
BootstrapCommand::from(linkchecker.arg(builder.out.join(host.triple).join("doc")))
.delay_failure(),
);
}
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@ -213,8 +216,11 @@ impl Step for HtmlCheck {
builder,
));
builder.run_delaying_failure(
builder.run_tracked(
BootstrapCommand::from(
builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)),
)
.delay_failure(),
);
}
}
@ -261,7 +267,7 @@ impl Step for Cargotest {
.env("RUSTC", builder.rustc(compiler))
.env("RUSTDOC", builder.rustdoc(compiler));
add_rustdoc_cargo_linker_args(cmd, builder, compiler.host, LldThreads::No);
builder.run_delaying_failure(cmd);
builder.run_tracked(BootstrapCommand::from(cmd).delay_failure());
}
}
@ -813,7 +819,7 @@ impl Step for RustdocTheme {
.env("RUSTC_BOOTSTRAP", "1");
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No));
builder.run_delaying_failure(&mut cmd);
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
}
}
@ -1093,7 +1099,7 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
}
builder.info("tidy check");
builder.run_delaying_failure(&mut cmd);
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
builder.info("x.py completions check");
let [bash, zsh, fish, powershell] = ["x.py.sh", "x.py.zsh", "x.py.fish", "x.py.ps1"]
@ -2179,7 +2185,8 @@ impl BookTest {
compiler.host,
);
let _time = helpers::timeit(builder);
let toolstate = if builder.run_delaying_failure(&mut rustbook_cmd) {
let cmd = BootstrapCommand::from(&mut rustbook_cmd).delay_failure();
let toolstate = if builder.run_tracked(cmd).is_success() {
ToolState::TestPass
} else {
ToolState::TestFail
@ -2371,7 +2378,8 @@ impl Step for RustcGuide {
let src = builder.src.join(relative_path);
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
let toolstate = if builder.run_delaying_failure(rustbook_cmd.arg("linkcheck").arg(&src)) {
let cmd = BootstrapCommand::from(rustbook_cmd.arg("linkcheck").arg(&src)).delay_failure();
let toolstate = if builder.run_tracked(cmd).is_success() {
ToolState::TestPass
} else {
ToolState::TestFail
@ -2985,7 +2993,7 @@ impl Step for Bootstrap {
.current_dir(builder.src.join("src/bootstrap/"));
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
// Use `python -m unittest` manually if you want to pass arguments.
builder.run_delaying_failure(&mut check_bootstrap);
builder.run_tracked(BootstrapCommand::from(&mut check_bootstrap).delay_failure());
let mut cmd = Command::new(&builder.initial_cargo);
cmd.arg("test")
@ -3062,7 +3070,7 @@ impl Step for TierCheck {
self.compiler.host,
self.compiler.host,
);
builder.run_delaying_failure(&mut cargo.into());
builder.run_tracked(BootstrapCommand::from(&mut cargo.into()).delay_failure());
}
}
@ -3148,7 +3156,7 @@ impl Step for RustInstaller {
cmd.env("CARGO", &builder.initial_cargo);
cmd.env("RUSTC", &builder.initial_rustc);
cmd.env("TMP_DIR", &tmpdir);
builder.run_delaying_failure(&mut cmd);
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
}
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

View File

@ -966,7 +966,11 @@ impl Build {
self.verbose(|| println!("running: {command:?}"));
let (output, print_error): (io::Result<CommandOutput>, bool) = match command.output_mode {
let output_mode = command.output_mode.unwrap_or_else(|| match self.is_verbose() {
true => OutputMode::PrintAll,
false => OutputMode::PrintOutput,
});
let (output, print_error): (io::Result<CommandOutput>, bool) = match output_mode {
mode @ (OutputMode::PrintAll | OutputMode::PrintOutput) => (
command.command.status().map(|status| status.into()),
matches!(mode, OutputMode::PrintAll),
@ -1028,16 +1032,6 @@ impl Build {
));
}
/// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
pub(crate) fn run_delaying_failure(&self, cmd: &mut Command) -> bool {
self.run_cmd(BootstrapCommand::from(cmd).delay_failure().output_mode(
match self.is_verbose() {
true => OutputMode::PrintAll,
false => OutputMode::PrintOutput,
},
))
}
/// 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() {
@ -1047,7 +1041,11 @@ impl Build {
let command = cmd.into();
self.verbose(|| println!("running: {command:?}"));
let (output, print_error) = match command.output_mode {
let output_mode = command.output_mode.unwrap_or_else(|| match self.is_verbose() {
true => OutputMode::PrintAll,
false => OutputMode::PrintOutput,
});
let (output, print_error) = match output_mode {
mode @ (OutputMode::PrintAll | OutputMode::PrintOutput) => (
command.command.status().map(|status| Output {
status,

View File

@ -28,7 +28,7 @@ pub enum OutputMode {
pub struct BootstrapCommand<'a> {
pub command: &'a mut Command,
pub failure_behavior: BehaviorOnFailure,
pub output_mode: OutputMode,
pub output_mode: Option<OutputMode>,
}
impl<'a> BootstrapCommand<'a> {
@ -50,17 +50,13 @@ impl<'a> BootstrapCommand<'a> {
}
pub fn output_mode(self, output_mode: OutputMode) -> Self {
Self { output_mode, ..self }
Self { output_mode: Some(output_mode), ..self }
}
}
impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
fn from(command: &'a mut Command) -> Self {
Self {
command,
failure_behavior: BehaviorOnFailure::Exit,
output_mode: OutputMode::PrintAll,
}
Self { command, failure_behavior: BehaviorOnFailure::Exit, output_mode: None }
}
}