Skip to content

Commit

Permalink
Remove usages of Config::try_run
Browse files Browse the repository at this point in the history
Commands should be run on Builder, if possible.
  • Loading branch information
Kobzol committed Oct 10, 2023
1 parent 3c01747 commit b2f121c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
15 changes: 6 additions & 9 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,12 @@ impl Build {
}

// Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error).
#[allow(deprecated)] // diff-index reports the modifications through the exit status
let has_local_modifications = self
.config
.try_run(
Command::new("git")
.args(&["diff-index", "--quiet", "HEAD"])
.current_dir(&absolute_path),
)
.is_err();
// diff-index reports the modifications through the exit status
let has_local_modifications = !self.run_cmd(
Command::new("git")
.args(&["diff-index", "--quiet", "HEAD"])
.current_dir(&absolute_path),
);
if has_local_modifications {
self.run(Command::new("git").args(&["stash", "push"]).current_dir(&absolute_path));
}
Expand Down
9 changes: 5 additions & 4 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::compile;
use crate::config::TargetSelection;
use crate::dist;
use crate::doc::DocumentationFormat;
use crate::exec::BootstrapCommand;
use crate::flags::Subcommand;
use crate::llvm;
use crate::render_tests::add_flags_and_try_run_tests;
Expand Down Expand Up @@ -801,8 +802,8 @@ impl Step for Clippy {

let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);

#[allow(deprecated)] // Clippy reports errors if it blessed the outputs
if builder.config.try_run(&mut cargo).is_ok() {
// Clippy reports errors if it blessed the outputs
if builder.run_cmd(&mut cargo) {
// The tests succeeded; nothing to do.
return;
}
Expand Down Expand Up @@ -3087,7 +3088,7 @@ impl Step for CodegenCranelift {
.arg("testsuite.extended_sysroot");
cargo.args(builder.config.test_args());

#[allow(deprecated)]
builder.config.try_run(&mut cargo.into()).unwrap();
let mut cmd: Command = cargo.into();
builder.run_cmd(BootstrapCommand::from(&mut cmd).fail_fast());
}
}
4 changes: 2 additions & 2 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ impl Step for ToolBuild {
);

let mut cargo = Command::from(cargo);
#[allow(deprecated)] // we check this in `is_optional_tool` in a second
let is_expected = builder.config.try_run(&mut cargo).is_ok();
// we check this in `is_optional_tool` in a second
let is_expected = builder.run_cmd(&mut cargo);

builder.save_toolstate(
tool,
Expand Down

0 comments on commit b2f121c

Please sign in to comment.