Remove run and rename run_tracked to run

This commit is contained in:
Jakub Beránek 2024-06-22 09:44:04 +02:00
parent 903d6a9d89
commit cf5bbb3a08
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
3 changed files with 23 additions and 32 deletions

View file

@ -156,7 +156,7 @@ fn run(self, builder: &Builder<'_>) {
let _guard =
builder.msg(Kind::Test, compiler.stage, "Linkcheck", bootstrap_host, bootstrap_host);
let _time = helpers::timeit(builder);
builder.run_tracked(
builder.run(
BootstrapCommand::from(linkchecker.arg(builder.out.join(host.triple).join("doc")))
.delay_failure(),
);
@ -216,7 +216,7 @@ fn run(self, builder: &Builder<'_>) {
builder,
));
builder.run_tracked(
builder.run(
BootstrapCommand::from(
builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)),
)
@ -267,7 +267,7 @@ fn run(self, builder: &Builder<'_>) {
.env("RUSTC", builder.rustc(compiler))
.env("RUSTDOC", builder.rustdoc(compiler));
add_rustdoc_cargo_linker_args(cmd, builder, compiler.host, LldThreads::No);
builder.run_tracked(BootstrapCommand::from(cmd).delay_failure());
builder.run(BootstrapCommand::from(cmd).delay_failure());
}
}
@ -766,7 +766,7 @@ fn run(self, builder: &Builder<'_>) {
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
// Clippy reports errors if it blessed the outputs
if builder.run_tracked(BootstrapCommand::from(&mut cargo).allow_failure()).is_success() {
if builder.run(BootstrapCommand::from(&mut cargo).allow_failure()).is_success() {
// The tests succeeded; nothing to do.
return;
}
@ -819,7 +819,7 @@ fn run(self, builder: &Builder<'_>) {
.env("RUSTC_BOOTSTRAP", "1");
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No));
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
builder.run(BootstrapCommand::from(&mut cmd).delay_failure());
}
}
@ -1097,7 +1097,7 @@ fn run(self, builder: &Builder<'_>) {
}
builder.info("tidy check");
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
builder.run(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"]
@ -2184,11 +2184,8 @@ fn run_ext_doc(self, builder: &Builder<'_>) {
);
let _time = helpers::timeit(builder);
let cmd = BootstrapCommand::from(&mut rustbook_cmd).delay_failure();
let toolstate = if builder.run_tracked(cmd).is_success() {
ToolState::TestPass
} else {
ToolState::TestFail
};
let toolstate =
if builder.run(cmd).is_success() { ToolState::TestPass } else { ToolState::TestFail };
builder.save_toolstate(self.name, toolstate);
}
@ -2317,8 +2314,7 @@ fn run(self, builder: &Builder<'_>) {
let guard =
builder.msg(Kind::Test, compiler.stage, "error-index", compiler.host, compiler.host);
let _time = helpers::timeit(builder);
builder
.run_tracked(BootstrapCommand::from(&mut tool).output_mode(OutputMode::OnlyOnFailure));
builder.run(BootstrapCommand::from(&mut tool).output_mode(OutputMode::OnlyOnFailure));
drop(guard);
// The tests themselves need to link to std, so make sure it is
// available.
@ -2351,7 +2347,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
if !builder.config.verbose_tests {
cmd = cmd.quiet();
}
builder.run_tracked(cmd).is_success()
builder.run(cmd).is_success()
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@ -2377,11 +2373,8 @@ fn run(self, builder: &Builder<'_>) {
let src = builder.src.join(relative_path);
let mut rustbook_cmd = builder.tool_cmd(Tool::Rustbook);
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
};
let toolstate =
if builder.run(cmd).is_success() { ToolState::TestPass } else { ToolState::TestFail };
builder.save_toolstate("rustc-dev-guide", toolstate);
}
}
@ -2994,7 +2987,7 @@ fn run(self, builder: &Builder<'_>) {
.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_tracked(BootstrapCommand::from(&mut check_bootstrap).delay_failure());
builder.run(BootstrapCommand::from(&mut check_bootstrap).delay_failure());
let mut cmd = Command::new(&builder.initial_cargo);
cmd.arg("test")
@ -3071,7 +3064,7 @@ fn run(self, builder: &Builder<'_>) {
self.compiler.host,
self.compiler.host,
);
builder.run_tracked(BootstrapCommand::from(&mut cargo.into()).delay_failure());
builder.run(BootstrapCommand::from(&mut cargo.into()).delay_failure());
}
}
@ -3157,7 +3150,7 @@ fn run(self, builder: &Builder<'_>) {
cmd.env("CARGO", &builder.initial_cargo);
cmd.env("RUSTC", &builder.initial_rustc);
cmd.env("TMP_DIR", &tmpdir);
builder.run_tracked(BootstrapCommand::from(&mut cmd).delay_failure());
builder.run(BootstrapCommand::from(&mut cmd).delay_failure());
}
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@ -3352,7 +3345,7 @@ fn run(self, builder: &Builder<'_>) {
cargo.args(builder.config.test_args());
let mut cmd: Command = cargo.into();
builder.run_tracked(BootstrapCommand::from(&mut cmd));
builder.run(BootstrapCommand::from(&mut cmd));
}
}
@ -3478,6 +3471,6 @@ fn run(self, builder: &Builder<'_>) {
cargo.args(builder.config.test_args());
let mut cmd: Command = cargo.into();
builder.run_tracked(BootstrapCommand::from(&mut cmd));
builder.run(BootstrapCommand::from(&mut cmd));
}
}

View file

@ -918,7 +918,7 @@ fn run(self, builder: &Builder<'_>) -> LibcxxVersion {
.arg(&executable)
.arg(builder.src.join("src/tools/libcxx-version/main.cpp"));
builder.run_tracked(BootstrapCommand::from(&mut cmd));
builder.run(BootstrapCommand::from(&mut cmd));
if !executable.exists() {
panic!("Something went wrong. {} is not present", executable.display());

View file

@ -581,7 +581,7 @@ pub(crate) fn update_submodule(&self, relative_path: &Path) {
// Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error).
// diff-index reports the modifications through the exit status
let has_local_modifications = self
.run_tracked(
.run(
BootstrapCommand::from(submodule_git().args(["diff-index", "--quiet", "HEAD"]))
.allow_failure(),
)
@ -959,11 +959,14 @@ fn rustc_snapshot_sysroot(&self) -> &Path {
}
/// Execute a command and return its output.
fn run_tracked(&self, command: BootstrapCommand<'_>) -> CommandOutput {
/// This method should be used for all command executions in bootstrap.
fn run<'a, C: Into<BootstrapCommand<'a>>>(&self, command: C) -> CommandOutput {
if self.config.dry_run() {
return CommandOutput::default();
}
let command = command.into();
self.verbose(|| println!("running: {command:?}"));
let output_mode = command.output_mode.unwrap_or_else(|| match self.is_verbose() {
@ -1022,11 +1025,6 @@ fn run_tracked(&self, command: BootstrapCommand<'_>) -> CommandOutput {
output
}
/// Runs a command, printing out nice contextual information if it fails.
fn run(&self, cmd: &mut Command) {
self.run_tracked(BootstrapCommand::from(cmd));
}
/// Check if verbosity is greater than the `level`
pub fn is_verbose_than(&self, level: usize) -> bool {
self.verbosity > level