Skip to content

Commit 0de7b92

Browse files
committed
Remove run_delaying_failure
1 parent e933cfb commit 0de7b92

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ You can skip linkcheck with --skip src/tools/linkchecker"
156156
let _guard =
157157
builder.msg(Kind::Test, compiler.stage, "Linkcheck", bootstrap_host, bootstrap_host);
158158
let _time = helpers::timeit(builder);
159-
builder.run_delaying_failure(linkchecker.arg(builder.out.join(host.triple).join("doc")));
159+
builder.run_tracked(
160+
BootstrapCommand::from(linkchecker.arg(builder.out.join(host.triple).join("doc")))
161+
.delay_failure(),
162+
);
160163
}
161164

162165
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -213,8 +216,11 @@ impl Step for HtmlCheck {
213216
builder,
214217
));
215218

216-
builder.run_delaying_failure(
217-
builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)),
219+
builder.run_tracked(
220+
BootstrapCommand::from(
221+
builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)),
222+
)
223+
.delay_failure(),
218224
);
219225
}
220226
}
@@ -261,7 +267,7 @@ impl Step for Cargotest {
261267
.env("RUSTC", builder.rustc(compiler))
262268
.env("RUSTDOC", builder.rustdoc(compiler));
263269
add_rustdoc_cargo_linker_args(cmd, builder, compiler.host, LldThreads::No);
264-
builder.run_delaying_failure(cmd);
270+
builder.run_tracked(BootstrapCommand::from(cmd).delay_failure());
265271
}
266272
}
267273

@@ -813,7 +819,7 @@ impl Step for RustdocTheme {
813819
.env("RUSTC_BOOTSTRAP", "1");
814820
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No));
815821

816-
builder.run_delaying_failure(&mut cmd);
822+
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
817823
}
818824
}
819825

@@ -1093,7 +1099,7 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
10931099
}
10941100

10951101
builder.info("tidy check");
1096-
builder.run_delaying_failure(&mut cmd);
1102+
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
10971103

10981104
builder.info("x.py completions check");
10991105
let [bash, zsh, fish, powershell] = ["x.py.sh", "x.py.zsh", "x.py.fish", "x.py.ps1"]
@@ -2179,7 +2185,8 @@ impl BookTest {
21792185
compiler.host,
21802186
);
21812187
let _time = helpers::timeit(builder);
2182-
let toolstate = if builder.run_delaying_failure(&mut rustbook_cmd) {
2188+
let cmd = BootstrapCommand::from(&mut rustbook_cmd).delay_failure();
2189+
let toolstate = if builder.run_tracked(cmd).is_success() {
21832190
ToolState::TestPass
21842191
} else {
21852192
ToolState::TestFail
@@ -2371,7 +2378,8 @@ impl Step for RustcGuide {
23712378

23722379
let src = builder.src.join(relative_path);
23732380
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
2374-
let toolstate = if builder.run_delaying_failure(rustbook_cmd.arg("linkcheck").arg(&src)) {
2381+
let cmd = BootstrapCommand::from(rustbook_cmd.arg("linkcheck").arg(&src)).delay_failure();
2382+
let toolstate = if builder.run_tracked(cmd).is_success() {
23752383
ToolState::TestPass
23762384
} else {
23772385
ToolState::TestFail
@@ -2985,7 +2993,7 @@ impl Step for Bootstrap {
29852993
.current_dir(builder.src.join("src/bootstrap/"));
29862994
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
29872995
// Use `python -m unittest` manually if you want to pass arguments.
2988-
builder.run_delaying_failure(&mut check_bootstrap);
2996+
builder.run_tracked(BootstrapCommand::from(&mut check_bootstrap).delay_failure());
29892997

29902998
let mut cmd = Command::new(&builder.initial_cargo);
29912999
cmd.arg("test")
@@ -3062,7 +3070,7 @@ impl Step for TierCheck {
30623070
self.compiler.host,
30633071
self.compiler.host,
30643072
);
3065-
builder.run_delaying_failure(&mut cargo.into());
3073+
builder.run_tracked(BootstrapCommand::from(&mut cargo.into()).delay_failure());
30663074
}
30673075
}
30683076

@@ -3148,7 +3156,7 @@ impl Step for RustInstaller {
31483156
cmd.env("CARGO", &builder.initial_cargo);
31493157
cmd.env("RUSTC", &builder.initial_rustc);
31503158
cmd.env("TMP_DIR", &tmpdir);
3151-
builder.run_delaying_failure(&mut cmd);
3159+
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
31523160
}
31533161

31543162
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

src/bootstrap/src/lib.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,11 @@ impl Build {
966966

967967
self.verbose(|| println!("running: {command:?}"));
968968

969-
let (output, print_error): (io::Result<CommandOutput>, bool) = match command.output_mode {
969+
let output_mode = command.output_mode.unwrap_or_else(|| match self.is_verbose() {
970+
true => OutputMode::PrintAll,
971+
false => OutputMode::PrintOutput,
972+
});
973+
let (output, print_error): (io::Result<CommandOutput>, bool) = match output_mode {
970974
mode @ (OutputMode::PrintAll | OutputMode::PrintOutput) => (
971975
command.command.status().map(|status| status.into()),
972976
matches!(mode, OutputMode::PrintAll),
@@ -1028,16 +1032,6 @@ impl Build {
10281032
));
10291033
}
10301034

1031-
/// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
1032-
pub(crate) fn run_delaying_failure(&self, cmd: &mut Command) -> bool {
1033-
self.run_cmd(BootstrapCommand::from(cmd).delay_failure().output_mode(
1034-
match self.is_verbose() {
1035-
true => OutputMode::PrintAll,
1036-
false => OutputMode::PrintOutput,
1037-
},
1038-
))
1039-
}
1040-
10411035
/// A centralized function for running commands that do not return output.
10421036
pub(crate) fn run_cmd<'a, C: Into<BootstrapCommand<'a>>>(&self, cmd: C) -> bool {
10431037
if self.config.dry_run() {
@@ -1047,7 +1041,11 @@ impl Build {
10471041
let command = cmd.into();
10481042
self.verbose(|| println!("running: {command:?}"));
10491043

1050-
let (output, print_error) = match command.output_mode {
1044+
let output_mode = command.output_mode.unwrap_or_else(|| match self.is_verbose() {
1045+
true => OutputMode::PrintAll,
1046+
false => OutputMode::PrintOutput,
1047+
});
1048+
let (output, print_error) = match output_mode {
10511049
mode @ (OutputMode::PrintAll | OutputMode::PrintOutput) => (
10521050
command.command.status().map(|status| Output {
10531051
status,

src/bootstrap/src/utils/exec.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub enum OutputMode {
2828
pub struct BootstrapCommand<'a> {
2929
pub command: &'a mut Command,
3030
pub failure_behavior: BehaviorOnFailure,
31-
pub output_mode: OutputMode,
31+
pub output_mode: Option<OutputMode>,
3232
}
3333

3434
impl<'a> BootstrapCommand<'a> {
@@ -50,17 +50,13 @@ impl<'a> BootstrapCommand<'a> {
5050
}
5151

5252
pub fn output_mode(self, output_mode: OutputMode) -> Self {
53-
Self { output_mode, ..self }
53+
Self { output_mode: Some(output_mode), ..self }
5454
}
5555
}
5656

5757
impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
5858
fn from(command: &'a mut Command) -> Self {
59-
Self {
60-
command,
61-
failure_behavior: BehaviorOnFailure::Exit,
62-
output_mode: OutputMode::PrintAll,
63-
}
59+
Self { command, failure_behavior: BehaviorOnFailure::Exit, output_mode: None }
6460
}
6561
}
6662

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy