Repository navigation
spirv tools: answer -h/--help with exit 0 - #1678
Conversation
spirv_gs_to_compute.py and spirv_metal_set0.py parse argv by hand, so --help fell into the arity check and printed the usage line to stderr with exit 2. Answer it with the usage on stdout and return 0, before reading vulkan_bindless.h in spirv_metal_set0, and pin both with a test.
AGVibecoder
left a comment
There was a problem hiding this comment.
Checked out 92f8b7c, which builds on current main, and ran it locally. Windows 11, Python 3.12.10, pytest in a venv. SPIRV-Tools and llvm-mc are not on PATH, so the four tests that need them skipped. No GPU needed, no game files.
pytest -q tests/test_spirv_gs_to_compute.py tests/test_spirv_metal_set0.py: 6 passed, 4 skipped.python -I tools/spirv_gs_to_compute.py -h/--helpandpython -I tools/spirv_metal_set0.py -h/--help: all exit 0 and print the usage on stdout.- No arguments still exits 2.
--print-layoutstill prints the table. - Negative control: with both tools reset to
main,-k helpgives 2 failed. git diff --check: clean.
The fix is correct. For spirv_metal_set0 the check comes before capacities(), so help works without the header. I had the same change locally and am dropping it in favour of this PR. Some optional extras, none of which block merging:
- The tests only cover
--help. Parametrizing over-htoo would cover both spellings. - Both test files now end without a trailing newline.
spirv_gs_to_computerepeats the usage string, which is now in the code twice (help and the arity error) plus once in the docstring. Printing__doc__, asmesh_compute_vsdoes after #1507, would keep them in sync and also show the SPIRV-Tools requirement.
— Claude Opus 5.5 (low effort), AI-assisted review
Help now answers both spellings and both test files end with a newline. spirv_gs_to_compute prints the usage from its docstring for help and the arity error, so the text cannot drift; the docstring also shows the SPIRV-Tools requirement, as mesh_compute_vs does.
|
Thanks @AGVibecoder ??all three suggestions are in, on head (updated)
|
|
Thanks @liang-kai-shui. I checked d426f78 the same way as before (Windows 11, Python 3.12.10, no SPIRV-Tools on PATH):
My approval stands. One tiny optional point: — Claude Opus 5.5 (high effort), AI-assisted |
|
Thanks @AGVibecoder ??agreed on the AI-assisted. |
Claimed in the coordination issue as: #1548 (comment)
What and why
tools/spirv_gs_to_compute.pyandtools/spirv_metal_set0.pyparsesys.argvby hand, so-h/--helpfalls into the arity check:Every other CLI tool in
tools/answers--helpwith exit 0. Both now print the usage on stdout and return 0, before the arity check (and beforespirv_metal_set0readsruntime/src/vulkan_bindless.hfor its capacities), so--helpalso works when the header or SPIRV-Tools are not present.Tested
pytest tests/test_spirv_metal_set0.py -q-> 4 passed (1 new).pytest tests/test_spirv_gs_to_compute.py -q-> 6 passed (1 new), with SPIRV-Tools and llvm-mc on PATH.--helpcommands now print the usage line and exit 0.mainin a separate worktree -> the new help test fails in each (exit 2 vs 0).python -m compileall -q ...andgit diff --checkclean.CPU only, no game files.
AI-assisted.
Checklist
docs/design.md??not applicable.