CI: require mutation coverage on changed lines #108

Closed
github-bot wants to merge 2 commits from gh-pr/108/head into gh-pr/108/base
Owner

@⁠dutch2005 on GitHub · 2026-11-25 14:18 UTC · original
ci/mutation-testing → main · +154 −0 · 4 files · 2 commits · closed without merging

Why

The project needs a defined quality bar for new code. Mutation testing makes "the test covers the change" mechanical: it mutates the changed lines and fails if the tests still pass. This is the Rust equivalent of mutmut/Stryker.

What

  • .cargo/mutants.toml: no target-directory copy (a stale build must not decide a result), lints capped so denied warnings do not make mutants unviable, 120 s minimum test timeout.
  • docs/mutation-testing.md: policy, local command, how to handle a surviving mutant, GPU/serial note, and the known Lower::new tool limitation.
  • .github/workflows/mutants.yml: on pull requests, fetch the base branch, diff it, and run cargo mutants --in-diff ... --timeout 300 --jobs 2. Only changed lines, so cost stays bounded.
  • README: a short "Tests and mutation coverage" section pointing at the policy.

Testing

  • cargo mutants --config .cargo/mutants.toml --list -p victory-core parses the config and lists mutants.
  • The workflow itself runs only after merge (GitHub does not run a PR's workflow file for fork PRs). The first real run will be on the next pull request.
  • Existing evidence the policy catches gaps: xmem first reported 2 caught / 1 missed; adding the large-reservation test made it 3/3. The wave64 condition was extracted to wants_wave_size, and the tool then found 9 mutants, all caught.

Notes

  • The baseline must be green for mutation results to mean anything. Known baseline failures are #2 (clippy) and #8 (xmem; fixed by #93).
  • The job is PR-only; pushes to main are covered by the normal CI.
  • If the job is considered too expensive, it can be scoped further with --package; the current form already only examines changed lines.
**@⁠dutch2005** on GitHub · 2026-11-25 14:18 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/108) `ci/mutation-testing` → `main` · +154 −0 · 4 files · 2 commits · closed without merging ## Why The project needs a defined quality bar for new code. Mutation testing makes "the test covers the change" mechanical: it mutates the changed lines and fails if the tests still pass. This is the Rust equivalent of mutmut/Stryker. ## What - `.cargo/mutants.toml`: no target-directory copy (a stale build must not decide a result), lints capped so denied warnings do not make mutants unviable, 120 s minimum test timeout. - `docs/mutation-testing.md`: policy, local command, how to handle a surviving mutant, GPU/serial note, and the known `Lower::new` tool limitation. - `.github/workflows/mutants.yml`: on pull requests, fetch the base branch, diff it, and run `cargo mutants --in-diff ... --timeout 300 --jobs 2`. Only changed lines, so cost stays bounded. - README: a short "Tests and mutation coverage" section pointing at the policy. ## Testing - `cargo mutants --config .cargo/mutants.toml --list -p victory-core` parses the config and lists mutants. - The workflow itself runs only after merge (GitHub does not run a PR's workflow file for fork PRs). The first real run will be on the next pull request. - Existing evidence the policy catches gaps: `xmem` first reported 2 caught / 1 missed; adding the large-reservation test made it 3/3. The wave64 condition was extracted to `wants_wave_size`, and the tool then found 9 mutants, all caught. ## Notes - The baseline must be green for mutation results to mean anything. Known baseline failures are #2 (clippy) and #8 (xmem; fixed by #93). - The job is PR-only; pushes to `main` are covered by the normal CI. - If the job is considered too expensive, it can be scoped further with `--package`; the current form already only examines changed lines.
Every change must come with tests that kill its mutants. Add cargo-mutants configuration, a contributor policy, and a pull-request job that runs cargo mutants --in-diff on the PR diff. Changed lines only, no target copy, lints capped so denied warnings do not make mutants unviable.
Equivalent mutants in wave.rs, xmem.rs and host.rs are documented instead of suppressed; note RUST_TEST_THREADS=1 and unviable/timeout mutants.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:53 +00:00
github-bot closed this pull request 2026-11-26 03:35:53 +00:00
Author
Owner

@⁠dutch2005 on GitHub · 2026-11-25 16:51 UTC · original

Rebased onto upstream/main (01aadd1) and updated the mutation workflow/docs to match:

  • .github/workflows/mutants.yml: set RUST_TEST_THREADS: "1" in the step env so xmem and GPU differential tests run serially on CI, and pass -e "xtask/**" until #72/#84 bring lower.rs under the 512 KiB asset-policy cap.
  • docs/mutation-testing.md: document RUST_TEST_THREADS=1 and the temporary xtask exclusion.
  • Verified cargo xtask policy --staged (2 files ok) and cargo mutants --in-diff pr108.diff -e "xtask/**" --timeout 300 --jobs 2 (INFO Diff changes no Rust source files, exit 0).
**@⁠dutch2005** on GitHub · 2026-11-25 16:51 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/108#issuecomment-7168647281) Rebased onto `upstream/main` (`01aadd1`) and updated the mutation workflow/docs to match: - **`.github/workflows/mutants.yml`**: set `RUST_TEST_THREADS: "1"` in the step `env` so `xmem` and GPU differential tests run serially on CI, and pass `-e "xtask/**"` until `#72`/`#84` bring `lower.rs` under the 512 KiB asset-policy cap. - **`docs/mutation-testing.md`**: document `RUST_TEST_THREADS=1` and the temporary `xtask` exclusion. - Verified `cargo xtask policy --staged` (`2 files ok`) and `cargo mutants --in-diff pr108.diff -e "xtask/**" --timeout 300 --jobs 2` (`INFO Diff changes no Rust source files`, exit 0).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.