Repository navigation
bvh_tri_probe: an unusable --write-kernels path is one error line and exit 2 - #6364
josevictorp wants to merge 2 commits into
Conversation
… exit 2 os.makedirs(out_dir, exist_ok=True) and the two open() calls in write_kernels() were not guarded, so --write-kernels pointing at an existing plain file died in a FileExistsError traceback (a path under one, in a NotADirectoryError) with exit 1, while the tool documents "2 a CLI or harness error" and its --json writer already answers with one error line and exit 2. The call in main() now catches OSError and prints "error: cannot write --write-kernels <dir>: <reason>" on stderr, the same wording its --json handler uses. Tested: a new CommandLine case in tests/test_bvh_tri_probe.py (two subCases: an existing file, a folder under one; each expects exit 2, one error line, no traceback); it errors without the guard and the file's 16 tests pass with it. tests/semantic (1010 tests) and python -m compileall over tools and tests are green. AI-assisted: written by Qwen (model qwen3.8-gx10-claude-compatible).
|
Tested 4ed3246 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass
AI-assisted (Claude Code). |
ItsNotRexed#6708 added two --json tests at the same spot in tests/test_bvh_tri_probe.py. Both blocks stay; 18 tests pass.
|
Merged
AI-assisted. |
|
Tested dd0baaf68ae07b119c1d72623b0a828d6e4ac369 on Linux x86-64, Python 3.14.9 (no GPU; code read + unit tests only): pass.
Code read: matches the |
shadshuvo
left a comment
There was a problem hiding this comment.
Code read (CPU) ?
Review
This PR correctly validates --write-kernels path before use, providing clean error messages.
Code Quality
? Early validation: Checks path is usable before proceeding
? Clean errors: One error line and exit 2 instead of traceback
? Test coverage: New test verifies both plain-file and missing-parent cases
? All 18 bvh_tri_probe tests pass (677 subtests)
Testing
npython -m pytest tests/test_bvh_tri_probe.py -xvs 18 passed, 677 subtests passed in 1.62s n
Ready to merge.
Reviewed on Windows 11, Python 3.14.2 (AI-assisted)
New BUILD item, claimed in #5934 (comment).
What was wrong. On
main561b65a8,write_kernels()intools/bvh_tri_probe.pycallsos.makedirsand twoopen()with no guard.--write-kernelspointing at an existing plain file ends in aFileExistsErrortraceback, and a path under a plain file in aNotADirectoryErrortraceback, both exit 1. The tool documents exit 2 for a CLI or harness error, and its--jsonwriter already answers with one error line and exit 2.What changed. The call in
main()catchesOSErrorand printserror: cannot write --write-kernels <dir>: <reason>on stderr, returning 2: the wording the--jsonhandler uses.Tested on Linux 6.8, Python 3.12.3, CPU only (no GPU, no driver, no game files):
python -I tests/test_bvh_tri_probe.py: OK, with the newCommandLinecase (two subcases: an existing file, a folder under one; exit 2, one error line, no traceback).tools/bvh_tri_probe.pyfrom561b65a8the same file ends inFAILED (errors=2).python -m compileall -q tools testsis clean.AI-assisted: written by Qwen, checked by Claude Code.