tools/spirv_loop_guard: preserve CRLF boundaries, validate limits and add unit tests #1842
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1842
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/spirv-loop-guard-safety"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: SPIRV-LOOP-GUARD-CRLF-SAFETY-AND-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163090236)
What and why
\rfrom_LINE(([^;\r\n]*)) intools/spirv_loop_guard.pyso Windows CRLF SPIR-V assembly does not split appendedOpPhiincoming pairs across a bare\r.parse_limit()withargparse.ArgumentTypeErrorand rejectbool/non-intlimits upfront inadd_guards()(ValueError).len(args) >= 2forOpConstantand raiseValueErrorwhen guard declarations are needed without anyOpFunctioninstead of failing withIndexErrororTypeError.tests/test_spirv_loop_guard.py.Tested
python -I tests/test_spirv_loop_guard.py -v->Ran 9 tests in 0.001s,OK.upstream/main(98c2f777) baseline worktree withtests/test_spirv_loop_guard.py->Ran 9 tests in 0.004s,FAILED (failures=4, errors=6).python -I tests/test_ci_registration.py->Ran 16 tests in 5.189s,OK.python -I tests/test_text_write_line_endings.py->Ran 3 tests in 11.779s,OK.python -I scripts/check_no_game_data.py tools/spirv_loop_guard.py tests/test_spirv_loop_guard.py-> exit0.python -I -m compileall -q tools/spirv_loop_guard.py tests/test_spirv_loop_guard.pyandgit diff --check-> exit0.GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)
AI-assisted: yes
Checklist
needs rebase).Tested
65055ca54on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain384abe5b0(Python shader tool; no GPU):tests/test_spirv_loop_guard.py: 9 passed, 13 subtests passed at this head.main: 10 failed, 6 passed, 6 subtests — the CRLF boundary andparse_limitvalidation cases are new (no test file existed before).AI-assisted; synthetic fixtures only, no game data.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_spirv_loop_guard.py:(AI-assisted test run; output checked by hand.)
#1842 | head
65055ca5440cfe42857b5e7b11ef442030f5b09c|python3 -I tests/test_spirv_loop_guard.py -v,py -3.12 -I tests/test_spirv_loop_guard.py -v| red: 9 run, 4 failures, 6 errors (Linux) / 9 run, 4 failures, 6 errors (Windows) | green: 9 passed (Linux) / 9 passed (Windows) | Red → greenThe file passed after the merge on Linux and Windows, including the test that checks CRLF boundaries during OpPhi rewriting.
Copied the PR tests onto clean main
4a54aedcb6b66525e0c9f72a6ea10263337c9141for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Native Windows used Python 3.12.10. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.Merged, thank you @kirigayakazima! This PR (tools/spirv_loop_guard: preserve CRLF boundaries, validate limits and add unit tests) passed its own tests with main merged in during sodove's verification of this shader batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.