Skip to main content

measure_python

Function measure_python 

Source
pub fn measure_python(
    root: &Path,
    exempt: &[String],
    exempt_lines: &BTreeMap<String, BTreeSet<u32>>,
    base: Option<&str>,
) -> Result<Vec<Survivor>>
Expand description

Run the bundled Python mutation adapter over the project at root and return its un-exempted survivors — the Python arm of the mutation rule (#203 / #248), parity with measure_rust and measure_typescript.

The tool drives the engine: the wheel ships a Python adapter that runs cosmic-ray through its own library API (WorkDB) and emits the normalized NormalizedMutant schema (#239) the gate consumes. maturin (bindings = "bin") ships the rust binary directly as the wheel’s script — with no Python launcher to inject a path, unlike the TS arm — so the binary invokes the adapter as an installed module (python3 -m testing_conventions.mutation.main), resolved from the wheel’s environment alongside cosmic-ray. The project supplies its own test runner (pytest), exactly as cargo-mutants needs a buildable crate and Stryker needs vitest.

With base set, only mutants on the <base>...HEAD changed lines are reported: cosmic-ray has no native git-diff mode, so the run is scoped to the changed .py files (passed as --module) and the survivors are filtered to the changed lines in the core — line granularity, matching the other arms. Without it, the whole project’s sources run (tests excluded). exempt is the file-level exempt paths and exempt_lines the line-scoped ones (#226).