Repository navigation
tests/semantic: move the __main__ guard last so a direct run covers the whole file - #3579
Conversation
Two test classes were defined after the __main__ guard, so `python -I tests/semantic/test_lds_atomic_inc_u32.py` ran 11 of the file's 19 tests and still printed OK. Move the guard to the end, as the rest of the suite does.
Same as the previous commit, for test_salu_pack_b32.py: the direct run covered 12 of its 16 tests.
|
Second check on Windows with Python 3.12.10. I ran both files directly with The verbose output confirmed that the restored direct-run classes cover the LDS bank-conflict and return-value cases and the SALU aliasing and negative controls. These were CPU-only checks. AI-assisted. |
kacper-serewis
left a comment
There was a problem hiding this comment.
Independent CPU validation at 023a7f6: compared the names collected by direct invocation and unittest discovery across the affected modules. Both paths ran the same 35 tests. AI-assisted, synthetic inputs only.
Claimed in the coordination issue as: a new tests item — #3381 (comment)
What and why
tests/semantic/test_lds_atomic_inc_u32.pyandtests/semantic/test_salu_pack_b32.pydefine test classes after theirif __name__ == "__main__":guard, so running either file the way its own docstring says runs only the classes defined above the guard — and still printsOK.Measured on
f847748:python -I <file>unittest discovertest_lds_atomic_inc_u32.pytest_salu_pack_b32.pytest_lds_atomic_inc_u32.pyprints both commands side by side in its docstring, so the two documented paths disagree with each other.CI is not affected: the semantic-tests job runs
python -m unittest discover -s tests/semantic, which imports the module, leaves the guard false and collects everything. This is the local-check path — someone iterating on a translator rule readsOKfor 11 of 19 LDS atomic tests, including the bank-conflict and return-value-preservation classes.The fix is to move the guard to the end of each file, which is what the rest of the suite does and what #3236 does for its two files. After it, both files run 19/19 and 16/16 in either mode.
Scope note: this does not overlap the open PRs in this area. #3236 covers
tests/test_shader_checks.pyandtests/test_rpf9_carve.py; #3122 and #3051 cover other files; #3203's runner meta-test is scoped to stdlib-modetests/test_*.pyand excludestests/semanticentirely. No dependency on any of them.Tested
No GPU and no game files; standard library only. On
f847748, Linux, Python 3.13.18:python -I tests/semantic/test_lds_atomic_inc_u32.py— 19 tests, OK (was 11)python -I tests/semantic/test_salu_pack_b32.py— 16 tests, OK (was 12)python -m unittest discover -s tests/semantic -p test_lds_atomic_inc_u32.py— 19 tests, OK (unchanged)python -m unittest discover -s tests/semantic -p test_salu_pack_b32.py— 16 tests, OK (unchanged)python -m unittest discover -s tests/semantic— 7322 tests, OK (4 skipped, 1 expected failure)python -m compileall -q make_game.py tools tests— cleanNo new test: the change adds no behaviour. It makes 12 existing tests run on a path where they silently did not, and the counts above are the check.
While confirming this I also looked at
tests/test_amd_swizzle.py, which has the same shape but must not be changed the same way: its six post-guard functions take the pytesttmp_pathfixture, so moving the guard makes itsglobals()runner raiseTypeError. It is pytest-mode in CI and all 8 run there. I left it alone and posted it as a separatefinding:in the claim above.AI-assisted (Claude).
Checklist
docs/design.md, with how it was confirmed. — n/a, this adds no translator rule.