Add ability to ignore certain failures (#461)

This commit is contained in:
Roey Darwish Dror
2020-07-02 11:15:56 +03:00
committed by GitHub
parent 3d4917fa88
commit 5c7f04c2cf
6 changed files with 161 additions and 226 deletions

View File

@@ -1,8 +1,25 @@
use std::borrow::Cow;
#[derive(Clone, Copy)]
pub enum StepResult {
Success,
Failure,
Ignored,
}
impl StepResult {
pub fn failed(self) -> bool {
match self {
StepResult::Success | StepResult::Ignored => false,
StepResult::Failure => true,
}
}
}
type CowString<'a> = Cow<'a, str>;
type ReportData<'a> = Vec<(CowString<'a>, StepResult)>;
pub struct Report<'a> {
data: Vec<(CowString<'a>, bool)>,
data: ReportData<'a>,
}
impl<'a> Report<'a> {
@@ -10,7 +27,7 @@ impl<'a> Report<'a> {
Self { data: Vec::new() }
}
pub fn push_result<M>(&mut self, result: Option<(M, bool)>)
pub fn push_result<M>(&mut self, result: Option<(M, StepResult)>)
where
M: Into<CowString<'a>>,
{
@@ -22,7 +39,7 @@ impl<'a> Report<'a> {
}
}
pub fn data(&self) -> &Vec<(CowString<'a>, bool)> {
pub fn data(&self) -> &ReportData<'a> {
&self.data
}
}