semantic_mutants: --source mutates any tools/ file, and tests outside tests/semantic run from a copy (MUTANTS-SOURCE) #1016

Manually merged
github merged 1 commit from gh-pr/1016/head into gh-pr/1016/base 2026-11-26 09:33:40 +00:00
Owner

@⁠qhukz13 on GitHub · 2026-11-24 16:56 UTC · original
qhukz13:cont/mutants-source → main · +136 −8 · 2 files · 1 commits · merged 2026-11-24 23:22 UTC

Claimed in the coordination issue as: MUTANTS-SOURCE

What and why

tools/semantic_mutants.py could only mutate tools/rdna2spirv.py, but much of the logic a test should catch lives in other tools: cfg_structure.py (structured CFG, see #808), lane_masks.py, wave64_emulate_opt.py, rdna2_decode.py (see #637). Reviewing those I had to write the mutations by hand.

  • --source tools/<file>.py picks the file to mutate (default tools/rdna2spirv.py, so existing uses are unchanged). --op, --function, --lines and the Python-logic mutations from #734 apply to it.
  • A tests/semantic file runs in place through LEONIDA_TOOLS_DIR, exactly as before.
  • Any other test of the repository imports tools/ by path, so a mutant in the private tools/ copy never reached it: reviewing #637, every mutant of rdna2_decode.py "survived" tests/test_rdna2_decode.py that way. Such a test now runs from a copy of the repository's tracked files (git ls-files, then tools/ and tests/ whole so untracked work comes along; a work folder inside the clone is never copied) with the mutant in that copy's tools/. It runs as a script when it has a __main__ block, since test_cfg_structure.py and test_lane_masks.py have no unittest class for run_test to find.
  • run_test is unchanged, so this does not overlap #863 or #987.

Tested

  • python -I tests/test_semantic_mutants.py: 23 tests OK. New SourceOption: --source must be a .py under tools/; a probe script in tests/ (outside tests/semantic) that imports tools/cfg_structure.py by path catches depth mutants, and the same probe without checks lets all of them survive.
  • On main: --source tools/rdna2_decode.py --lines <the VOP3 0x140 rename> tests/test_rdna2_decode.py catches 2 of 2; --source tools/cfg_structure.py --function depth tests/test_cfg_structure.py catches 2 of 4 (two statement removals in depth survive, a lead for a test). The default --lines 11766-11776 tests/semantic/test_alu_div_fixup_f32.py behaves as before.
  • compileall, tests/test_text_write_line_endings.py, scripts/check_no_game_data.py: OK. tests/test_tool_stdout_encoding.py fails on main with and without this change (tools/native_pso_hashes.py, claimed separately).

Linux, CPU only; no GPU, no game files.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠qhukz13** on GitHub · 2026-11-24 16:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1016) `qhukz13:cont/mutants-source` → `main` · +136 −8 · 2 files · 1 commits · merged 2026-11-24 23:22 UTC Claimed in the coordination issue as: MUTANTS-SOURCE ### What and why `tools/semantic_mutants.py` could only mutate `tools/rdna2spirv.py`, but much of the logic a test should catch lives in other tools: `cfg_structure.py` (structured CFG, see #808), `lane_masks.py`, `wave64_emulate_opt.py`, `rdna2_decode.py` (see #637). Reviewing those I had to write the mutations by hand. - `--source tools/<file>.py` picks the file to mutate (default `tools/rdna2spirv.py`, so existing uses are unchanged). `--op`, `--function`, `--lines` and the Python-logic mutations from #734 apply to it. - A `tests/semantic` file runs in place through `LEONIDA_TOOLS_DIR`, exactly as before. - Any other test of the repository imports `tools/` by path, so a mutant in the private `tools/` copy never reached it: reviewing #637, every mutant of `rdna2_decode.py` "survived" `tests/test_rdna2_decode.py` that way. Such a test now runs from a copy of the repository's tracked files (`git ls-files`, then `tools/` and `tests/` whole so untracked work comes along; a work folder inside the clone is never copied) with the mutant in that copy's `tools/`. It runs as a script when it has a `__main__` block, since `test_cfg_structure.py` and `test_lane_masks.py` have no unittest class for `run_test` to find. - `run_test` is unchanged, so this does not overlap #863 or #987. ### Tested - `python -I tests/test_semantic_mutants.py`: 23 tests OK. New `SourceOption`: `--source` must be a `.py` under `tools/`; a probe script in `tests/` (outside `tests/semantic`) that imports `tools/cfg_structure.py` by path catches `depth` mutants, and the same probe without checks lets all of them survive. - On `main`: `--source tools/rdna2_decode.py --lines <the VOP3 0x140 rename> tests/test_rdna2_decode.py` catches 2 of 2; `--source tools/cfg_structure.py --function depth tests/test_cfg_structure.py` catches 2 of 4 (two statement removals in `depth` survive, a lead for a test). The default `--lines 11766-11776 tests/semantic/test_alu_div_fixup_f32.py` behaves as before. - `compileall`, `tests/test_text_write_line_endings.py`, `scripts/check_no_game_data.py`: OK. `tests/test_tool_stdout_encoding.py` fails on `main` with and without this change (`tools/native_pso_hashes.py`, claimed separately). Linux, CPU only; no GPU, no game files. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The tool could only mutate tools/rdna2spirv.py, but much of the logic a test should catch lives in other tools:
cfg_structure.py, lane_masks.py, wave64_emulate_opt.py, rdna2_decode.py. `--source tools/<file>.py` (default
tools/rdna2spirv.py, so existing uses are unchanged) picks the file; --op/--function/--lines and the Python-logic
mutations apply to it.

A tests/semantic file runs in place through LEONIDA_TOOLS_DIR, as before. Any other test of the repository imports
tools/ by path, so a mutant in the private tools/ copy never reached it (reviewing #637, every mutant of
rdna2_decode.py "survived" test_rdna2_decode.py that way). Such a test now runs from a copy of the repository's
tracked files (git ls-files, then tools/ and tests/ whole for untracked work) with the mutant in that copy's tools/,
and as a script when it has a `__main__` block, since test_cfg_structure.py and test_lane_masks.py have no unittest
class. run_test is unchanged.

On main: `--source tools/rdna2_decode.py` on the VOP3 0x140 rename with tests/test_rdna2_decode.py catches 2 of 2;
`--source tools/cfg_structure.py --function depth` with tests/test_cfg_structure.py catches 2 of 4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:33:39 +00:00
github manually merged commit dbc0c74360 into gh-pr/1016/base 2026-11-26 09:33:40 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 17:00 UTC · original · approved these changes

Verified on exact head dbc0c74360. python3 -I -B tests/test_semantic_mutants.py passes 23/23; scripts/check_no_game_data.py for both changed files and git diff --check pass. I independently reproduced the external-script path with --source tools/cfg_structure.py --function depth tests/test_cfg_structure.py: 2/4 mutants were caught, and the two surviving statement removals match the PR description. The run against the empty-check probe also confirms mutations survive when the probe asserts nothing. A broader _decode_one mutation run exceeded the review environment’s 30-second command window and is not claimed here. CPU-only synthetic tests; no GPU or game data.

**@⁠KernelSmoker** on GitHub · 2026-11-24 17:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1016#pullrequestreview-6043748333) · **approved these changes** Verified on exact head dbc0c74360b36298ec86f8f1c8a16bde34f6d285. `python3 -I -B tests/test_semantic_mutants.py` passes 23/23; `scripts/check_no_game_data.py` for both changed files and `git diff --check` pass. I independently reproduced the external-script path with `--source tools/cfg_structure.py --function depth tests/test_cfg_structure.py`: 2/4 mutants were caught, and the two surviving statement removals match the PR description. The run against the empty-check probe also confirms mutations survive when the probe asserts nothing. A broader `_decode_one` mutation run exceeded the review environment’s 30-second command window and is not claimed here. CPU-only synthetic tests; no GPU or game data.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 23:22 UTC · original

Merging.

Why merged: MUTANTS-SOURCE: semantic_mutants gets a --source tools/X.py option, and tests outside tests/semantic run from a temporary copy of the repo (git ls-files plus a copy), so mutation testing reaches the tools too. It's a small tool feature. KernelSmoker approved and reproduced it.

Why it's good: It only spawns git and the user's own test file under -I, nothing external. 23 passed (about 2 minutes, really mutating cfg_structure).

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 0f98d193c. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 23:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1016#issuecomment-7147326114) Merging. **Why merged:** MUTANTS-SOURCE: semantic_mutants gets a `--source tools/X.py` option, and tests outside tests/semantic run from a temporary copy of the repo (git ls-files plus a copy), so mutation testing reaches the tools too. It's a small tool feature. KernelSmoker approved and reproduced it. **Why it's good:** It only spawns git and the user's own test file under `-I`, nothing external. 23 passed (about 2 minutes, really mutating cfg_structure). Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 0f98d193c. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.