Allow ignoring the failure of command execution
This commit is contained in:
parent
b153a01828
commit
5d7fca15d3
@ -810,7 +810,7 @@ impl Step for Clippy {
|
|||||||
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
|
let _guard = builder.msg_sysroot_tool(Kind::Test, compiler.stage, "clippy", host, host);
|
||||||
|
|
||||||
// Clippy reports errors if it blessed the outputs
|
// Clippy reports errors if it blessed the outputs
|
||||||
if builder.run_cmd(&mut cargo) {
|
if builder.run_cmd(BootstrapCommand::from(&mut cargo).allow_failure()) {
|
||||||
// The tests succeeded; nothing to do.
|
// The tests succeeded; nothing to do.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ use crate::core::build_steps::toolstate::ToolState;
|
|||||||
use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
|
use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
|
||||||
use crate::core::config::TargetSelection;
|
use crate::core::config::TargetSelection;
|
||||||
use crate::utils::channel::GitInfo;
|
use crate::utils::channel::GitInfo;
|
||||||
|
use crate::utils::exec::BootstrapCommand;
|
||||||
use crate::utils::helpers::{add_dylib_path, exe, t};
|
use crate::utils::helpers::{add_dylib_path, exe, t};
|
||||||
use crate::Compiler;
|
use crate::Compiler;
|
||||||
use crate::Mode;
|
use crate::Mode;
|
||||||
@ -109,7 +110,7 @@ impl Step for ToolBuild {
|
|||||||
|
|
||||||
let mut cargo = Command::from(cargo);
|
let mut cargo = Command::from(cargo);
|
||||||
// we check this in `is_optional_tool` in a second
|
// we check this in `is_optional_tool` in a second
|
||||||
let is_expected = builder.run_cmd(&mut cargo);
|
let is_expected = builder.run_cmd(BootstrapCommand::from(&mut cargo).allow_failure());
|
||||||
|
|
||||||
builder.save_toolstate(
|
builder.save_toolstate(
|
||||||
tool,
|
tool,
|
||||||
|
@ -581,9 +581,12 @@ impl Build {
|
|||||||
// Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error).
|
// 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
|
// diff-index reports the modifications through the exit status
|
||||||
let has_local_modifications = !self.run_cmd(
|
let has_local_modifications = !self.run_cmd(
|
||||||
|
BootstrapCommand::from(
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["diff-index", "--quiet", "HEAD"])
|
.args(&["diff-index", "--quiet", "HEAD"])
|
||||||
.current_dir(&absolute_path),
|
.current_dir(&absolute_path),
|
||||||
|
)
|
||||||
|
.allow_failure(),
|
||||||
);
|
);
|
||||||
if has_local_modifications {
|
if has_local_modifications {
|
||||||
self.run(Command::new("git").args(&["stash", "push"]).current_dir(&absolute_path));
|
self.run(Command::new("git").args(&["stash", "push"]).current_dir(&absolute_path));
|
||||||
@ -1009,6 +1012,7 @@ impl Build {
|
|||||||
BehaviorOnFailure::Exit => {
|
BehaviorOnFailure::Exit => {
|
||||||
exit!(1);
|
exit!(1);
|
||||||
}
|
}
|
||||||
|
BehaviorOnFailure::Ignore => {}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ pub enum BehaviorOnFailure {
|
|||||||
Exit,
|
Exit,
|
||||||
/// Delay failure until the end of bootstrap invocation.
|
/// Delay failure until the end of bootstrap invocation.
|
||||||
DelayFail,
|
DelayFail,
|
||||||
|
/// Ignore the failure, the command can fail in an expected way.
|
||||||
|
Ignore,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How should the output of the command be handled.
|
/// How should the output of the command be handled.
|
||||||
@ -33,9 +35,15 @@ impl<'a> BootstrapCommand<'a> {
|
|||||||
pub fn delay_failure(self) -> Self {
|
pub fn delay_failure(self) -> Self {
|
||||||
Self { failure_behavior: BehaviorOnFailure::DelayFail, ..self }
|
Self { failure_behavior: BehaviorOnFailure::DelayFail, ..self }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fail_fast(self) -> Self {
|
pub fn fail_fast(self) -> Self {
|
||||||
Self { failure_behavior: BehaviorOnFailure::Exit, ..self }
|
Self { failure_behavior: BehaviorOnFailure::Exit, ..self }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn allow_failure(self) -> Self {
|
||||||
|
Self { failure_behavior: BehaviorOnFailure::Ignore, ..self }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn output_mode(self, output_mode: OutputMode) -> Self {
|
pub fn output_mode(self, output_mode: OutputMode) -> Self {
|
||||||
Self { output_mode, ..self }
|
Self { output_mode, ..self }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user