shader: harden spirv_address_window CLI guards and add CLI suite #2656
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2664"
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 R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-26T01:32:25Z.
Change
Harden CLI argument and path validation in
tools/spirv_address_window.pyand add a pure-Python mocked-subprocess CLI test suite (tests/spirv_address_window_cli_check.py), registered inCMakeLists.txtasshader_spirv_address_window_cli_check._validate_args()thatsourceexists and is a regular file (not a directory),outputis not a symlink, directory, same path/hardlink assource, or under a non-directory parent/ancestor, and--assembler/--validatorare non-empty stripped strings.subprocess.run()while preserving atomicTemporaryDirectory+Path.replace()output publishing and clean exit code1with zero raw tracebacks.tests/spirv_address_window_check.py.Verification
Tested on commit
1a876e12(based onupstream/mainf06646ba) on Windows usingout/pe-env/Scripts/python.exe -B:out\pe-env\Scripts\python.exe -B tests\spirv_address_window_check.py-> exit 0 (spirv_address_window: unit lowering, composed passes, and CLI error handling passed).out\pe-env\Scripts\python.exe -B tests\spirv_address_window_cli_check.py-> exit 0 (7/7 tests OK, 0 skips: atomic nested write/overwrite, zero leftover temp dirs, live & dangling symlink guards, missing/dir/bad-UTF8 source, output dir/file-parent/samefile/hardlink guards, empty/whitespace--assembler/--validator, mockedCalledProcessError/FileNotFoundError/TimeoutExpired/Path.replacecleanup, and Python 3.14-safe argparse checks).out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py-> exit 0 (form coverage checks passed).out\pe-env\Scripts\python.exe -B tests\docs_links_check.py-> exit 0 (19 Markdown files, 510 links).out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py-> exit 0 (no bidirectional controls).tests/spirv_address_window_cli_check.py): disablingargs.output.is_symlink(), disabling empty--validatorcheck, and disabling non-directory output parent check.Evidence and follow-up
tests/spirv_window/subtract.spvasm(MIT License) with mockedsubprocess.runso it runs offline without externalspirv-as/spirv-valbinaries.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:36:38Z.
Review: COMMENTED
Review of head
1a876e12against origin/main. No blocking findings._validate_argsmoves the CLI guards into one place: same-path, directory/missing/non-regular source, symlink or directory output, non-directory output parent, blank--assembler/--validator. Stripped values are the ones passed tosubprocess.run. Looks correct.tests/spirv_address_window_cli_check.py(7 tests) is registered in CMake asshader_spirv_address_window_cli_checknext to the siblingspirv_address_window_check.Commands run in a worktree on this head:
python3 -B tests/spirv_address_window_cli_check.py-> 7 tests OKpython3 tests/docs_links_check.py-> OKpython3 tests/bidi_controls_check.py-> OKgit diff --check origin/main...HEAD-> cleanif False:-> 3 failuresif False:-> 2 failuresPython-only change; Windows checks are not expected to be affected.
AI-assisted; commands listed were executed locally.