Skip to main content

Module mutation

Module mutation 

Source
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.
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.
NormalizedMutant
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::EngineNotRun from an all-killed Measurement::Tested keeps a vacuous pass visible, and a counted pass carries its own evidence.
MutantStatus
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 mutation exemption. evaluate_scoped generalizes this to per-line exemptions.
evaluate_normalized
Gate a normalized result set: drop the survivors lifted by a file- or line-scoped mutation exemption (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 mutation exemptions to the raw survivors, 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 root and return the Measurement — the Python arm, parity with measure_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 root and return the Measurement, or Measurement::EngineNotRun for a base diff 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 root and return the Measurement — the TS arm, parity with measure_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 inconclusive Timeout / 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.json export.
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 mutation exemption — the rule’s findings. exempt is the resolved set of crate-root-relative exempt paths; a survivor in an exempt file is dropped.

Type Aliases§

MutatedLines
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).