Expand description
Mutation testing (unit mutation) — the rung above coverage: a test that runs a
line still passes if you delete its assertions, and a surviving mutant proves it. Each
language drives its engine through an adapter; this module measures, the CLI layer gates.
Structs§
- LineCol
- A line/column position; only the line is read.
- Mutant
Info - The mutant a scenario describes, pared to the location + description the report
needs. cargo-mutants also carries
function,genre,package,replacement; those are ignored. - Mutant
Outcome - One scenario’s outcome.
summaryis cargo-mutants’ result word —Successfor the unmutated baseline,CaughtMutant/MissedMutant(andTimeout/Unviable) for each mutant. - Mutants
Report - A cargo-mutants
outcomes.jsonexport, pared to what the rule reads. Unmodeled fields (total_mutants,caught, timings, …) are ignored. - Normalized
Mutant - One mutant in the normalized result set: the engine-agnostic shape every language adapter emits. Extra fields an adapter includes are ignored.
- Span
- A source span; the start and end lines are read.
- Survivor
- A surviving mutant — a mutation the unit suite ran but failed to catch.
Enums§
- Measurement
- One mutation measurement: whether the engine ran, and what it found. Telling
Measurement::EngineNotRunfrom an all-killedMeasurement::Testedkeeps a vacuous pass visible, and a counted pass carries its own evidence. - Mutant
Status - A mutant’s outcome, normalized across the engines (Stryker / cosmic-ray / cargo-mutants)
so the Rust core gates on one representation instead of three report formats. The
serialized form is
snake_case(no_coverage,compile_error, …) — the adapters’ wire contract. - Scenario
- The scenario a result came from: the unmutated baseline, or one mutant. Matches
cargo-mutants’ externally-tagged JSON (
"Baseline"vs{"Mutant": {…}}).
Functions§
- evaluate
- The shared whole-file evaluation core: drop the survivors lifted by a file-level
mutationexemption.evaluate_scopedgeneralizes this to per-line exemptions. - evaluate_
normalized - Gate a normalized result set: drop the survivors lifted by a file- or line-scoped
mutationexemption (with the determinism guard), leaving the rule’s findings. This is the engine-agnostic core each language arm feeds once its adapter has normalized. - evaluate_
scoped - Apply file- and line-scoped
mutationexemptions to the rawsurvivors, with the determinism guard: a listed line whose mutants were all caught is over-exemption and a hard error, while a listed line with no mutant is left alone (it may be off the diff). - measure_
python - Run the bundled Python mutation adapter over the project at
rootand return theMeasurement— the Python arm, parity withmeasure_rust. maturin ships the binary directly, so it invokes the adapter as a module resolved from the wheel’s own environment. - measure_
rust - Run cargo-mutants over the crate at
rootand return theMeasurement, orMeasurement::EngineNotRunfor abasediff that changes no lines — or no Rust source — under the crate. The tool provisions cargo-mutants itself ([ensure_cargo_mutants]). - measure_
typescript - Run the bundled TypeScript mutation adapter over the scan path at
rootand return theMeasurement— the TS arm, parity withmeasure_rust. The adapter runs at the package root and its results are rebased scan-path-relative, so exemption paths match every check. - mutated_
lines - The
(file, line)locations cargo-mutants produced a viable, conclusive mutant for — caught or missed, not the inconclusiveTimeout/Unviable. The line-scoped guard reads this to tell an over-exemption from a line that has no mutant at all. - parse_
mutants_ report - Parse a cargo-mutants
outcomes.jsonexport. - parse_
normalized_ results - Parse the normalized results an engine adapter emits — a flat JSON array of
NormalizedMutant. - unexplained_
survivors - The surviving mutants not lifted by a
mutationexemption — the rule’s findings.exemptis the resolved set of crate-root-relative exempt paths; a survivor in an exempt file is dropped.
Type Aliases§
- Mutated
Lines - The
(file, line)locations an engine produced a viable mutant for — the input the line-scoped guard reads to tell an over-exemption (a listed line whose mutants were all caught) from an out-of-scope line (no mutant there).