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 <noreply@anthropic.com>
The tool only mutated SPIR-V emission (opcode pairs, self.cu constants, OpSelect arms, the last operand), so the
translator's analysis code - register liveness, lane-mask tracking, operand checks - got no mutants at all:
`--function read_before_write_vgprs` listed 0. Mutate its names and operators by token, so strings, f-strings and
comments stay as they are: comparisons flipped (== / !=, < / <=, > / >=, in / not in, is / is not; the `in` of a
for loop or comprehension stays), and / or, a `not` dropped, True / False, and a one-line statement that can fail
silently replaced by `pass` (a call that is not an emit, an augmented assignment, a rebinding of a name assigned
earlier in the range). The branch's own `if op ...` condition is left alone. Repeated labels on one line are
numbered from the left.
On #658's read_before_write_vgprs with its test file: 36 mutants, 27 caught; the survivors include the
`carried.difference_update(dst)` removal found equivalent by hand in that review, and `regs += x["r"]` (vlist
operands), which no case reaches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #660 (lixonik): a comment holding `"""` before a docstring flipped the delimiter count, so a --lines range
inside the docstring was mutated as code, and a docstring written as adjacent literals ("a " "b") was not recognised.
Follow triple-quote delimiters with a small scanner that skips comments, one-line strings and escaped delimiters,
and take a run of adjacent string tokens ending the statement as one docstring. A literal that is read by the code
after it stays code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on ItsNotRexed/Leonida#9432 (Gevroska): `--lines 595-595` falls inside u16_half's docstring, so the tokenized slice had no
opening delimiter and the text was mutated as code. Widen the tokenized span to whole triple-quoted strings,
counting delimiters from the enclosing def or class (a text scan, cheap inside the long dispatch method).
Every one of the translator's 1,049 docstring lines now gives 0 mutants as a one-line range.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mutants_for treated any line that starts with a quote as code (meant for `f"... OpIAdd ..."` emit lines), so a
docstring that names an opcode or GLSL op produced mutants that can never fail a test and were always reported
SURVIVED: `--function nminmax_f32` listed 5 mutants, 4 of them in its docstring, and 47 across rdna2spirv.py.
Tokenize the mutated range (dedented) and skip strings that stand alone as a statement; a range that does not
tokenize keeps the old behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Twelve test files failed on main at 2d53a8055 (CI's check and semantic-tests steps, run locally): most are a test
and the code it checks changed by different pull requests in the same merge round. Each fix below is either taken
from a closed pull request that already had it, or restores what an earlier merged change intended.
From closed pull requests:
- test_make_game_resume: FakeProc gets poll(), which translate() now calls (#7018)
- test_make_game_empty_translation: the Exited stub gets poll() and the failed-shard path is checked (#7214)
- test_shader_checks: stub table_fetch_test in the Wave64Checks harness and count it (#7433)
- test_runtime_paths: runtime.yml's path filter lists tools/replace_retry.py, which rdna2spirv.py imports (#7029)
- test_psin_names: patch the same_report_path helpers that report_paths now calls (#8719)
- test_report_source_collision: the fixture is a real Bink 2 header; bink_index refuses other files (#7408)
- test_missing_input_exit_codes: tile_probe checks its inputs before it asks for numpy (#4771)
Restored:
- merge_check: a failed `git show` is an error again (5b88d58); 21016cf brought back the lenient read that
treated it as a new file, while new files are already left out when the diff is read
- rpf_probe: a symlinked --out updates its target again (44d3595); 55d21cc's staged write replaced the link
Updated to the code:
- test_shader_stage_resume: TRANSLATION_SOURCES lists fssm_unpack.py and shader_stage_manifest.py, which the
translator imports; existing work folders translate once more after this
- test_tool_stdout_encoding: the 15 programs merged without the stdout guard get the same block as the others
- test_rdna2spirv_decode: drop the test of decode_any_format, which SHADER-849 replaced with the table decode
that tests/semantic/test_format_decode_table.py checks
Co-authored-by: jewmaster1337 <102986566+jewmaster1337@users.noreply.github.com>
Co-authored-by: TanmaySatyam <248538550+TanmaySatyam@users.noreply.github.com>
Co-authored-by: evilclanker9000 <45567075+evilclanker9000@users.noreply.github.com>
Co-authored-by: slint6614-dev <359954236+slint6614-dev@users.noreply.github.com>
Co-authored-by: BlackNife <108077267+Poussistar@users.noreply.github.com>
Co-authored-by: fiestorra <65175643+fiestorra@users.noreply.github.com>
Co-authored-by: fearkov <289226582+fearkov@users.noreply.github.com>
Co-authored-by: DoubleD17 <48109637+DoubleD17@users.noreply.github.com>
run_test started `python <file>`. Eight tests/semantic files have no `__main__` block, so that ran no tests,
exited 0, passed the baseline and reported every mutant SURVIVED (test_bfi_known_mask.py: 0 of 9 caught for
--op v_bfi_b32, 9 of 9 after this change). Run `python -m unittest <module>` from the test's folder as
tests/semantic/test_mutations.py does, treat unittest's exit status 5 (no tests ran) as a baseline error, and
pass LEONIDA_TOOLS_DIR as an absolute path now that the working directory changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>