CI: require mutation coverage on changed lines #108

Closed
dutch2005 wants to merge 2 commits from upstream-pr/108 into main
dutch2005 commented 2026-11-25 14:18:51 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by dutch2005 on 2026-11-25T14:18:51Z.


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.
<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:6606581835 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/108). Originally posted by [dutch2005](https://github.com/dutch2005) on 2026-11-25T14:18:51Z. --- ## 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 commented 2026-11-25 16:51:53 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by dutch2005 on 2026-11-25T16:51:53Z.


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).
<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7168647281 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/108#issuecomment-7168647281). Originally posted by [dutch2005](https://github.com/dutch2005) on 2026-11-25T16:51:53Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Belobug/VIctory-Belobug-AMD!108
No description provided.