Skip to content

rdna2spirv: an output write that fails is one error line and exit 2, not a traceback - #8470

Open
ne1i wants to merge 1 commit into
ItsNotRexed:mainfrom
ne1i:rdna2spirv-output-write-failure
Open

ne1i wants to merge 1 commit into
ItsNotRexed:mainfrom
ne1i:rdna2spirv-output-write-failure

Conversation

@ne1i

@ne1i ne1i commented Nov 23, 2026

Copy link
Copy Markdown

When a per-shader output could not be written, main() raised: a module path that is a directory (IsADirectoryError from the staged replace), a .spvasm path that is a directory, or an --out without write permission (PermissionError from the listing write). Each was a traceback that aborted the run.

Each is now one ERROR: <shader>: cannot write <path>: <reason> line and exit 2, with nothing retired. I followed the tool's own precedent for a missing spirv-as (one setup-error line, exit 2) rather than the per-shader "error and continue" rule, because every later shader writes to the same folder and the failing path may be the very module the retire step would delete. If maintainers prefer "continue with exit 1" here, that is a small change.

Unchanged: a missing spirv-as/spirv-val keeps its own message, and a run that succeeds is byte-identical; the new positive-control test asserts the module bytes, the index entry, empty stderr and that a second run leaves every output unchanged.

Not covered, on purpose: a failed delete of the diagnostic listing under --no-asm, and the final index.json write, whose staging #8109 is already reworking.

Relation to other open PRs: independent of #8253 (different lines; the two merge cleanly, checked with git merge-tree). #6263 changes the missing-assembler handling in the same except block, so one of the two may need a small rebase.

Tested on Linux, CPython 3.14, CPU only, synthetic listings, with the assembler stubbed in-process so the tests do not need SPIRV-Tools: python -I tests/test_rdna2spirv_cli.py Ran 39, OK (skipped=1); with only the tool reverted, the three new failure tests error with the raw exceptions. compileall, check_no_game_data.py and git diff --check are clean. The agent also ran it with SPIRV-Tools off PATH (39, OK, skipped=2); I did not repeat that run for this branch.

Claim: #8047.

AI-assisted (DeepSeek V4.1 Flash wrote it; gated and re-run with Claude Code).

@Grimkeh Grimkeh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Linux CPU review (69a89bd2)

What changed: failed writes of the listing / module under --out become one ERROR: … cannot write … line and exit 2 via write_error, instead of a traceback or treating a non-assembler OSError as a missing spirv-as.

Checked:

  • Diff covers both the early ASM write and the post-assemble listing write; missing spirv-as/val path unchanged.
  • python3 -I tests/test_rdna2spirv_cli.py → 39 OK (3 skipped).

Looks correct; no game files.

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed \69a89bd27641727ac5e10f74145ba1615c21b487\ on Windows 11 CPU (CPython 3.12.10, clean-room synthetic fixtures only, zero game data): pass.

Test Suite Execution

  • \python -I tests/test_rdna2spirv_cli.py OutputWriteFailure: 3 passed, 1 skipped (0.18s).
    • Verifies \ est_a_module_path_that_is_a_directory_is_one_error_line: exits 2 with \ERROR: ps_x: cannot write ...\ps_x.spv: ...\ without a traceback, leaves no index.json marker, and does not retire shaders.
    • Verifies \ est_a_spvasm_path_that_is_a_directory_is_one_error_line: exits 2 with single line \ERROR: ps_x: cannot write ...\ps_x.spvasm: ...\ without a traceback.
    • Verifies \ est_a_normal_run_is_byte_identical_when_run_twice: positive control confirms repeatable byte-for-byte identical output and successful translation (\1 shaders: 1 translated, 1 pass spirv-val).
    • \ est_an_out_without_write_permission_is_one_error_line: safely skipped on Windows as expected due to POSIX 0o555 directory permission semantics (\chmod 555 does not deny a write here).
  • Full CLI suite: \python -I tests/test_rdna2spirv_cli.py: 37 passed, 2 skipped (6.03s), clean.

Negative Control

Reverted \ ools/rdna2spirv.py\ to \origin/main\ (\�84730902) while running \OutputWriteFailure:

  • Failed with 2 errors:
    • \PermissionError: [WinError 5] Access is denied\ (uncaught traceback during \os.replace\ over existing directory at module target).
    • \PermissionError: [Errno 13] Permission denied\ (uncaught traceback during open for \ps_x.spvasm).
  • Restoring \69a89bd27\ cleanly resolved both tracebacks into exit code 2 setup error diagnostics.

Clean-Room & Repository Hygiene

  • \python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_rdna2spirv_cli.py: clean (0 violations).
  • \git diff --check origin/main: clean (no trailing whitespace or CRLF mix-ups).
  • \python -m compileall -q tools/rdna2spirv.py tests/test_rdna2spirv_cli.py: clean.

LGTM!

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 69a89bd2 on Windows 11 (Python 3.14.3, CPU-only, no game files): pass.

Test Suite Execution

  • python -I tests/test_rdna2spirv_cli.py -v: 37/39 passed (2 skipped as expected) in 10.36s.
    • Successfully verifies test_a_module_path_that_is_a_directory_is_one_error_line: converts OSError/PermissionError/IsADirectoryError during .replace() into a clean single ERROR: ps_x: cannot write <path>: ... line and exit 2.
    • Successfully verifies test_a_spvasm_path_that_is_a_directory_is_one_error_line: cleanly traps open() failure writing .spvasm and reports exit 2.
    • Successfully verifies test_a_normal_run_is_byte_identical_when_run_twice (positive control: identical output on rerun, index.json valid, stderr empty).

Negative Control

Reverted tools/rdna2spirv.py to origin/main while testing against tests/test_rdna2spirv_cli.py:

  • test_a_module_path_that_is_a_directory_is_one_error_line: FAILED (errors=1) — crashes with uncaught PermissionError: [WinError 5] Access is denied / IsADirectoryError during staged replace traceback.
  • test_a_spvasm_path_that_is_a_directory_is_one_error_line: FAILED (errors=1) — crashes with uncaught PermissionError: [Errno 13] Permission denied traceback.
    Restoring 69a89bd2 cleanly restores green.

Hygiene Checks

  • python -m compileall -q tools/rdna2spirv.py tests/test_rdna2spirv_cli.py: clean.
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_rdna2spirv_cli.py: clean, no game data.
  • git diff --check: clean.
  • Line endings: strict Unix LF (\n) preserved.

LGTM!

AI-assisted: verified and reviewed on Windows 11 environment.

@morodirule

Copy link
Copy Markdown

Tested 69a89bd on Arch Linux, Python 3.14.10, CPU only: pass, first Linux check. tests/test_rdna2spirv_cli.py 39 ran OK (1 skipped). Negative control: merge-base tools/rdna2spirv.py gives 3 errors (OutputWriteFailure cases); restored, green again. No game files. AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants