Skip to main content

Module mutation

Module mutation 

Source
Expand description

Mutation testing as evidence: after a passing verdict, the attempt’s changed code is mutated and the tests run against each mutant. A mutant the tests do not catch (“survivor”) is code the tests do not really check — the shape of a test written to pass rather than to verify.

[mutation] tool = "cargo-mutants" runs cargo mutants --in-diff on the attempt’s patch. tool = "command" runs any tool that writes the standard mutation-testing JSON report (Stryker, Infection, PIT with its plugin, …): argv may use {diff}, {out}, {files} (one argument per changed source file) and {files_csv}, and report names the JSON file.

mode = "report" (default) records the result as evidence; "require" fails the verdict when mutants survive, and the retry digest names them.

The same tool measures the acceptance set’s strength: the mutants run against the acceptance command only (run_against). suite = false keeps the tool for that alone; acceptance_argv is the command tool’s invocation then, with {tests} for the acceptance command.

Structs§

Config
[mutation].

Enums§

Mode
What survivors mean.
Tool
Which tool.

Functions§

acceptance_invocation
The argv that mutates the changed code and runs acceptance against each mutant; Err: why it cannot be measured.
cargo_test_args
What cargo mutants passes to cargo test to run only acceptance (cargo test --test accept → --test accept); None when the acceptance command is not a cargo test.
changed_sources
Source files a patch changes (+++ b/<path>), tests excluded.
failure
The verdict reason for survivors (mode = "require"), if any; a tool that could not run is a failure too (no evidence is not good evidence).
from_cargo_mutants
The result of cargo mutants (mutants.out/outcomes.json).
from_report_schema
The result in the mutation-testing report schema (Stryker and others): files.<path>.mutants[].status — Killed, Survived, NoCoverage, Timeout, CompileError, RuntimeError, Ignored.
parse
Reads [mutation]; None when absent.
run
Runs config’s tool on patch in project; None when the patch changes no source file. Scratch files go to tmp, outside the worktree.
run_against
run with the mutants judged by acceptance alone: the result as run’s, or {"error"} when it cannot be measured.
source_patch
patch with only the sections of changed source files: test files — the acceptance tests among them — removed.
trailer
The commit trailer value.