pub enum Outcome {
Pass,
Fail,
Skip,
Timeout,
Error,
}Expand description
What a run said about one test.
NotRun is deliberately absent: it is the absence of an execution, not an outcome one
had. Encoding it here would let a recorder write “this did not run” and have it counted
among the things that did.
use majordomus_cli::evidence::Outcome;
assert!(Outcome::parse("ok").proves());
assert!(!Outcome::parse("timeout").proves());
// exactly one of the five is evidence of anything; the other four are reasons there
// is none, kept apart because "it declined" and "the harness broke" are different bugs
assert_eq!(Outcome::parse("skipped"), Outcome::Skip);
assert_eq!(Outcome::parse("nonsense"), Outcome::Error);§Example
use majordomus_cli::evidence::Outcome;
assert!(Outcome::parse("ok").proves());
assert_eq!(Outcome::parse("wat"), Outcome::Error);Variants§
Pass
It passed.
Fail
It failed.
Skip
It declined to run and said so (an unmet precondition the case reports itself).
Timeout
The bound fired before it finished.
Error
The harness could not run it at all.
Implementations§
Source§impl Outcome
impl Outcome
Sourcepub fn proves(self) -> bool
pub fn proves(self) -> bool
Did this run prove the behaviour it was about? Only a pass does.
A skip is a test that declined, and a timeout or an error is a test whose verdict nobody has; none of the three is a weaker kind of success, and every derivation in this module asks this question rather than matching on the variants itself.
use majordomus_cli::evidence::Outcome;
assert!(Outcome::Pass.proves());
assert!(!Outcome::Skip.proves(), "a test that declined to run proved nothing");
assert!(!Outcome::Timeout.proves());
assert!(!Outcome::Error.proves());Sourcepub fn parse(word: &str) -> Outcome
pub fn parse(word: &str) -> Outcome
The word the runner writes, read back. Anything unrecognised is Outcome::Error:
a result nobody can classify is not a pass.
Case and surrounding space are the runner’s business, not the ledger’s, so both are normalised away. The fallback is the whole point: a truncated line, a renamed status word or a new runner’s vocabulary fails loudly instead of widening into a green.
use majordomus_cli::evidence::Outcome;
assert_eq!(Outcome::parse("PASSED"), Outcome::Pass);
assert_eq!(Outcome::parse(" skip "), Outcome::Skip);
// near-misses included: nothing here guesses at what was meant
assert_eq!(Outcome::parse("okay"), Outcome::Error);
assert!(!Outcome::parse("").proves());Trait Implementations§
impl Copy for Outcome
Source§impl<'de> Deserialize<'de> for Outcome
impl<'de> Deserialize<'de> for Outcome
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Outcome
Source§impl JsonSchema for Outcome
impl JsonSchema for Outcome
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for Outcome
impl Ord for Outcome
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Outcome
impl PartialOrd for Outcome
impl StructuralPartialEq for Outcome
Auto Trait Implementations§
impl Freeze for Outcome
impl RefUnwindSafe for Outcome
impl Send for Outcome
impl Sync for Outcome
impl Unpin for Outcome
impl UnsafeUnpin for Outcome
impl UnwindSafe for Outcome
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.