Skip to main content

Module mutation

Module mutation 

Source
Expand description

Mutation testing for Rust (unit mutation --language rust, #201) — the rung above coverage. A test that runs a line still passes if you delete its assertions; a surviving mutant proves it. This module wraps cargo-mutants: it runs the engine, reads its outcomes.json, and reports the surviving mutants the suite failed to catch.

The gate is binary, not a percentage (equivalent mutants make a fixed score unreachable, and a score isn’t comparable across engines) and on by default: any un-exempted surviving mutant is a finding. This module stays a pure measurement — measure_rust returns the survivors and unexplained_survivors is the pure core over a parsed report; the CLI layer turns a non-empty result into the failure.

Diff-scoping (--base) is delegated to cargo-mutants’ own --in-diff: the <base>...HEAD diff is written out and passed through, so only mutants on changed lines are tested (“no unexplained surviving mutant on the lines you touched”).

Structs§

LineCol
A line/column position; only the line is read.
MutantInfo
The mutant a scenario describes, pared to the location + description the report needs. cargo-mutants also carries function, genre, package, replacement; those are ignored.
MutantOutcome
One scenario’s outcome. summary is cargo-mutants’ result word — Success for the unmutated baseline, CaughtMutant / MissedMutant (and Timeout / Unviable) for each mutant.
MutantsReport
A cargo-mutants outcomes.json export, pared to what the rule reads. Unmodeled fields (total_mutants, caught, timings, …) are ignored.
Span
A source span; only the start line is read.
StrykerFile
One file’s mutants in a Stryker report.
StrykerLocation
A mutant’s source location; only the start line is read (reusing LineCol, whose extra column field Stryker also provides and serde ignores).
StrykerMutant
One mutant, pared to the location + status + description the rule needs. Stryker also carries id, coveredBy, static, testsCompleted, …; those are ignored.
StrykerReport
A Stryker mutation.json report (the mutation-testing-elements schema), pared to the fields the rule reads. Unmodeled keys (schemaVersion, thresholds, source, testFiles, projectRoot, config, …) are ignored.
Survivor
A surviving mutant — a mutation the unit suite ran but failed to catch.

Enums§

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 evaluation core both engines feed: drop the survivors lifted by a mutation exemption (a file-path match), leaving the rule’s findings. Each engine produces the raw survivor list its own way (unexplained_survivors from a cargo-mutants report, stryker_survivors from a Stryker report); this applies the reason-required exemptions identically across languages.
measure_rust
Run cargo-mutants over the crate at root and return its un-exempted survivors.
measure_typescript
Run Stryker over the TypeScript project at root and return its un-exempted survivors — the TS arm of the mutation rule (#202), parity with measure_rust.
parse_mutants_report
Parse a cargo-mutants outcomes.json export.
parse_stryker_report
Parse a Stryker mutation.json report.
stryker_survivors
The surviving mutants in a Stryker report — the raw list before exemptions.
unexplained_survivors
The surviving mutants not lifted by a mutation exemption — the rule’s findings.