Repository navigation
tools/rdna2spirv: reject a --out that is a file (new BUILD item) - #2475
ItsNotRexed merged 1 commit into
Conversation
Validate --out right after parsing arguments: a file, a path under a file, a dangling symlink or an unmapped drive root is now one argparse error line with exit 2, instead of a FileExistsError/NotADirectoryError traceback, and before --merge or os.makedirs can write anything. Matches the guards in shader_disasm.py (ItsNotRexed#1607) and tex_export.py (ItsNotRexed#1632). Add subprocess tests for those paths and a control that a new output folder with missing parents still translates. CPU-only; no game data.
|
Tested |
|
Tested Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows
By hand on Windows,
In each case the file was left as it was. A small cosmetic point: in the second case the message names the parent by its long path, while the The suite's 193 modules are byte-identical to AI-assisted (Claude Code); I checked the results. |
|
Tested 4a03e78 on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
Claim: new BUILD item in the coordination issue #2300 — claim comment. The coordinator did not assign a numeric item ID (it was claimed as an unlisted one-line item).
Depends on: none.
What
tools/rdna2spirv.pyvalidatedsrcbut never--out. A regular file at--out, a path under a file, a dangling symlink or an unmapped Windows drive root used to abort with an uncaughtFileExistsError/NotADirectoryErrortraceback (and the--mergepath failed later inwrite_index).The guard now runs right after
parse_args(), before--mergeand before anyos.makedirs(): one argparse error line, exit 2, no traceback, and nothing created, modified or overwritten. Wording follows the same guards inshader_disasm.py(#1607) andtex_export.py(#1632). Ancestor lookup usesrealpathso symlinked..components resolve the wayos.makedirsuses them, and stops at a non-existent root instead of looping forever.No
docs/design.mdchange: this is input validation, not a translator rule.Verification
python -m compileall -q make_game.py tools tests— pass.python -I tests/test_rdna2spirv_cli.py -v— 25 tests, OK, 1 skipped (creating symlinks needs a Windows privilege not held here; the skip reason is explicit). New cases cover a file at--out, a path under a file,--outwith--merge, a trailing path separator, an unmapped drive root, and a control that a new folder with missing parents still translates.python -m unittest discover -s tests/semantic -v— 2567 tests, OK (3 skipped).python -I make_game.py --help— pass.abspathcollapsed..across symlink components, fixed by usingrealpath; (2) an unmapped drive root made the ancestor walk loop forever, fixed by stopping at a root whose parent is itself, with a regression test. Final review: no new findings. The third finding was about a pre-existing stale submodule checkout in my working tree, not this diff; I aligned the submodule to the branch's gitlink and it is absent from the PR.git status/git diff: onlytools/rdna2spirv.pyandtests/test_rdna2spirv_cli.py. No game data, shaders, logs or reports quoting them.