shader: reject a non-positive --limit in extract_shaders #639

Merged
louisdibiasi merged 2 commits from upstream-pr/645 into main 2026-11-22 18:31:29 +00:00
louisdibiasi commented 2026-11-22 17:16:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-22T17:16:34Z.


Change

tools/extract_shaders.py tested the --limit count only after it had written a record, and accepted any integer. --limit 0 and --limit -1 therefore extracted the first record, wrote a manifest and exited 0, as if the limit were 1. This rejects a limit below 1 with parser.error before the archive is read.

Independent problem, no linked issue.

Verification

Commit under test: f8d4dab on b03f754, Windows 11, Python 3.12.10.

Two-record synthetic archive, python -B tools/extract_shaders.py limit.rpf --output-dir out --stage pixel --limit N:

  • Base: N=0 and N=-1 each extract one record (PS_First), exit 0.
  • This branch: N=0 and N=-1 print error: --limit must be at least 1, exit 2, no output directory; N=1 still extracts exactly one record.

New TestRdna2Extractor.test_cli_limit_must_be_positive covers 0, -1 and 1.

  • Base: fails.
  • This branch: python -B tests/rdna2_tools_check.py -> Ran 51 tests ... OK (skipped=1). The skip is test_llvm_comparison (LLVM_LIB not set on my machine).

Evidence and follow-up

Synthetic archive built by the test; no game files. LLVM-backed comparison not run here; it is unrelated to the extractor CLI.

Checklist

  • One reviewable behavior.
  • Exact commands and results above.
  • Negative control: the new test fails on base.
  • No README/docs change needed.
  • No game files, dumps, links or secrets.

AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6545330307 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/645). Originally posted by [louisdibiasi](https://github.com/louisdibiasi) on 2026-11-22T17:16:34Z. --- ## Change `tools/extract_shaders.py` tested the `--limit` count only after it had written a record, and accepted any integer. `--limit 0` and `--limit -1` therefore extracted the first record, wrote a manifest and exited 0, as if the limit were 1. This rejects a limit below 1 with `parser.error` before the archive is read. Independent problem, no linked issue. ## Verification Commit under test: f8d4dab on b03f754, Windows 11, Python 3.12.10. Two-record synthetic archive, `python -B tools/extract_shaders.py limit.rpf --output-dir out --stage pixel --limit N`: - Base: N=0 and N=-1 each extract one record (`PS_First`), exit 0. - This branch: N=0 and N=-1 print `error: --limit must be at least 1`, exit 2, no output directory; N=1 still extracts exactly one record. New `TestRdna2Extractor.test_cli_limit_must_be_positive` covers 0, -1 and 1. - Base: fails. - This branch: `python -B tests/rdna2_tools_check.py` -> `Ran 51 tests ... OK (skipped=1)`. The skip is `test_llvm_comparison` (`LLVM_LIB` not set on my machine). ## Evidence and follow-up Synthetic archive built by the test; no game files. LLVM-backed comparison not run here; it is unrelated to the extractor CLI. ## Checklist - [x] One reviewable behavior. - [x] Exact commands and results above. - [x] Negative control: the new test fails on base. - [x] No README/docs change needed. - [x] No game files, dumps, links or secrets. AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.
upstream-sync closed this pull request 2026-11-24 06:44:08 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!639
No description provided.