Add ability to ignore certain failures (#461)
This commit is contained in:
committed by
GitHub
parent
3d4917fa88
commit
5c7f04c2cf
@@ -1,8 +1,8 @@
|
||||
use crate::ctrlc;
|
||||
use crate::error::SkipStep;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::report::Report;
|
||||
use crate::terminal::should_retry;
|
||||
use crate::report::{Report, StepResult};
|
||||
use crate::{config::Step, terminal::should_retry};
|
||||
use anyhow::Result;
|
||||
use log::debug;
|
||||
use std::borrow::Cow;
|
||||
@@ -21,18 +21,22 @@ impl<'a> Runner<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn execute<F, M>(&mut self, key: M, func: F) -> Result<()>
|
||||
pub fn execute<F, M>(&mut self, step: Step, key: M, func: F) -> Result<()>
|
||||
where
|
||||
F: Fn() -> Result<()>,
|
||||
M: Into<Cow<'a, str>> + Debug,
|
||||
{
|
||||
if !self.ctx.config().should_run(step) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let key = key.into();
|
||||
debug!("Step {:?}", key);
|
||||
|
||||
loop {
|
||||
match func() {
|
||||
Ok(()) => {
|
||||
self.report.push_result(Some((key, true)));
|
||||
self.report.push_result(Some((key, StepResult::Success)));
|
||||
break;
|
||||
}
|
||||
Err(e) if e.downcast_ref::<SkipStep>().is_some() => {
|
||||
@@ -44,11 +48,19 @@ impl<'a> Runner<'a> {
|
||||
ctrlc::unset_interrupted();
|
||||
}
|
||||
|
||||
let should_ask = interrupted || !self.ctx.config().no_retry();
|
||||
let ignore_failure = self.ctx.config().ignore_failure(step);
|
||||
let should_ask = interrupted || !(self.ctx.config().no_retry() || ignore_failure);
|
||||
let should_retry = should_ask && should_retry(interrupted, key.as_ref())?;
|
||||
|
||||
if !should_retry {
|
||||
self.report.push_result(Some((key, false)));
|
||||
self.report.push_result(Some((
|
||||
key,
|
||||
if ignore_failure {
|
||||
StepResult::Ignored
|
||||
} else {
|
||||
StepResult::Failure
|
||||
},
|
||||
)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user