Enum RuleOutcome
pub enum RuleOutcome {
Ran,
Skipped {
capability: &'static str,
reason: &'static str,
},
}Expand description
What a conformance rule did.
There is no Failed variant, and its absence is deliberate: a failing rule
panics. That is what fails the enclosing #[test], and it is what gives
libtest a message, a location and a backtrace to print. Threading failure
back as a value would buy a second, worse reporting channel.
The #[must_use] is what turns “an emitter must report the skip” from prose
into a build failure. A caller-supplied emitter that drops the outcome warns,
and CI denies warnings.
Variants§
Ran
The rule ran, and every assertion in it held.
Skipped
The rule required a capability this fixture declines, and did nothing.
Fields
capability: &'static strThe associated const that was declined, as its own identifier —
"REOPEN" on a Fixture, "RESET_REFUSAL" on a
ProjectionFixture — so a reader is told the name of the thing
they can go and change rather than a paraphrase of it. Both fixture
traits report into this one field, and a test asserting on a skip can
therefore spell the constant’s name directly.
Two values here are not fixture consts and are spelled with their
path for that reason: NO_STORE_LIMITS and NO_BATCH_READ_PATH.
reason: &'static strThe fixture’s stated reason, from Capability::declined — except
for the two testkit-written reasons, NO_CEILING_REASON and
NO_BATCH_READ_PATH_REASON, which each say on their own page why
the fixture is not asked to phrase it.
Implementations§
§impl RuleOutcome
impl RuleOutcome
pub fn skip_line(self, rule: &str) -> Option<String>
pub fn skip_line(self, rule: &str) -> Option<String>
The one line worth showing a human, or None when there is nothing to
say.
This is the target-independent half of reporting, and it is public
because where a line goes is a property of the harness rather than of
the rule. report writes it to stdout, which is right on
every target that has one; emit_wasm routes it to console.log,
because wasm32-unknown-unknown does not (see report).
A caller-supplied emitter for a runtime the testkit has never heard of —
CF-23’s extension point — picks its own sink from here.
The returned Option is itself #[must_use], so the obligation to
report survives one step further down the chain.
pub fn report(self, rule: &str)
pub fn report(self, rule: &str)
Reports this outcome to stdout, under the name of the rule that produced it.
Prints nothing for Ran — libtest already reports a test
that passed — and one SKIP line for a skip.
§Two honest limitations, one per target
Natively, libtest suppresses a passing test’s stdout unless it is run
with --show-output (or --nocapture), which is why the gate passes it.
That makes the line reachable by a human; it does not make anyone read
it. The machine-checked half of the obligation is the
mutation_coverage::capability_skips_are_reported meta-test in
crates/happenstance-testkit/tests/mutation_coverage.rs, which asserts on
RuleOutcome values rather than on stdout — and not this function.
On wasm32-unknown-unknown this function is a no-op, measured rather
than assumed: the suite was run under wasm-bindgen-test-runner with
--nocapture and no SKIP line appeared. That target’s std has no
host stdio to write to and declares no import that would give it one, and
wasm-bindgen-test hooks console.* rather than println!. So the wasm
emitter does not call this; it calls skip_line and
hands the result to console_log!, which the runner does capture.