tools/cf_diff: validate CLI args, isolate SPIRV_VAL state, and enforce UTF-8 subprocess decoding #1859
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1859"
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?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T13:20:54Z.
Claimed in the coordination issue as: CF-DIFF-CLI-VALIDATION-STATE-ISOLATION-AND-ENCODING (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163606026)
What and why
--minimizewithout--program, negative--program, and negative--depthviaap.error(...)intools/cf_diff.py:main().--spirv-valtool errors (spirv-as/spirv-val) tosys.stderrinstead ofstdout, returning2before mutating module-globalSPIRV_VAL.SPIRV_VALupdates insidetry ... finally: SPIRV_VAL = prev_spirv_valinmain()so in-process callers cannot leakSPIRV_VAL = Trueafter normal return or exceptions.encoding="utf-8", errors="replace"tosubprocess.runin_spirv_val()to avoid platform code-page decode failures on tool output.unittestCLI and encoding regression coverage intests/test_cf_diff_cli.py.Tested
python -I tests/test_cf_diff_cli.py -v->Ran 4 tests in 0.007s(OK).upstream/main98c2f777withtests/test_cf_diff_cli.pycopied into detached worktree):Ran 4 tests in 10.120s(FAILED (failures=6)across all subtests and cases).python -I tests/test_ci_registration.py(Ran 16 tests in 5.521s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 13.010s,OK),python -I scripts/check_no_game_data.py(exit 0),python -I -m compileall -q(exit 0),git diff --check(exit 0).GPUs tested: n/a (CLI validation, state isolation, and mocked subprocess unittest suite)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-25T14:03:38Z.
Tested
7fd52fa61on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain71a769d7d(Python GPU diff tool; no campaign run):tests/test_cf_diff_cli.py: 4 passed, 3 subtests passed at this head.main: 6 failed, 1 passed — the CLI argument guards, theSPIRV_VALstate isolation and the UTF-8 subprocess encoding are the new coverage.cf_diffcampaign on the GPU; the tests mock the tools.AI-assisted; synthetic fixtures only, no game data.
Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:32:15Z.
Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.
python -m pytest -q tests/test_cf_diff_cli.py:tools/cf_diff.py: 6 failed, 1 passed. So the tests catch the problem, and the tool change fixes it on Windows.(AI-assisted test run; output checked by hand.)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:56:53Z.
Red/green: tests/test_cf_diff_cli.py fails 6 assertions on main (CLI argument guards, SPIRV_VAL state leak, UTF-8 subprocess decoding) and passes with the PR.
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
cb7a239ccin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)