Skip to main content

Module assertions

Module assertions 

Source
Expand description

The eight built-in assertions (spec 003).

One shared implementation, the way crate::steps is one shared implementation. Before this module ExecutionContext::evaluate_assertion was a required trait method with no in-tree body outside a test double, so every execution mode was free to answer differently; now they share this and conformance/corpus/assertion_cases.json measures it.

TypeReadsDetail
output_containsraw_outputcontains <repr>
output_not_containsraw_outputdoes not contain <repr>
screen_containsscreencontains <repr>
screen_not_containsscreendoes not contain <repr>
exit_codeexit_codeexpected <str>, got <str>
file_existsthe filesystemthe resolved path
file_containsthe filesystemcontains <repr>
json_schemaraw_outputone of nine (FR-016)

json_schema is the one row behind a feature. It needs the jsonschema crate, which is 87 of the crate’s 180 transitive dependencies, so the json-schema feature — on by default — decides whether it is compiled. Off, it is absent from BUILTIN_TYPES and dispatch reports it the way it reports any name it does not know; the other seven are unaffected.

Nothing here can end a run. FR-020 supersedes the oracle, which raises out of evaluate_assertions on eight different malformed inputs and discards every result already collected. Each of those becomes a failed AssertionResult instead, so a report is never truncated by an earlier assertion — a partial report is worse than none.

Constants§

BUILTIN_TYPES
The assertion types this crate answers for, in the order the config declares them.

Functions§

builtin_registry
The built-in registry, for a caller that needs to know whether a name is claimed before dispatching (FR-024).
evaluate
Evaluate one assertion.
evaluate_all
Evaluate every assertion a recipe declares, including the synthetic one.
evaluated_list
The assertions a recipe evaluates, in order (FR-019).
score
The score a set of assertion results earns (FR-022): the fraction that passed, and 1.0 when there are none to fail.