Scripts: harden check_layout CLI argument handling and binary lookup #1187

Open
heditrigui wants to merge 1 commit from upstream-pr/1196 into main
heditrigui commented 2026-11-24 13:05:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by heditrigui on 2026-11-24T13:05:07Z.


Harden scripts/re/check_layout.py CLI invocation and binary lookup:

  • Print usage and exit cleanly when invoked with -h or --help (exit code 0), and exit with code 2 on missing arguments, avoiding an unhandled IndexError.
  • Look up xcl executable via XCL_EXE environment variable, falling back to target/release/xcl.exe and target/debug/xcl.exe.
  • Provide informative stderr error messages when the specified directory or xcl binary is missing instead of throwing unhandled tracebacks.
  • Add scripts/test_check_layout.py covering CLI help flags, exit codes on missing arguments/directories/binaries, synthetic RTS0 layout parsing, and mock disassembly matching.

Tested

  • python -B -m unittest discover -s scripts -p "test_*.py" -v: 16 passed, 0 failed.
  • Tested scripts/re/check_layout.py --help (exits 0 with usage docstring).
  • Tested scripts/re/check_layout.py with no args (exits 2 with usage docstring).
  • Tested scripts/re/check_layout.py non_existent_dir (exits 1 with clear diagnostic).
  • Validated PR description and changed files with scripts/pr_check.py --local.

Not tested

  • Retail game smoke tests: this PR modifies only offline analysis scripts in scripts/ and does not touch runtime code or dependencies.

AI use
Antigravity (Gemini 3.8 Flash (High)) designed the CLI argument handling and fallback resolution, implemented unit tests in scripts/test_check_layout.py, ran the test suite, and verified PR conventions.

<!-- greyfinch-sync:ivall/xcl:issue:5472696447 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1196). Originally posted by [heditrigui](https://github.com/heditrigui) on 2026-11-24T13:05:07Z. --- Harden `scripts/re/check_layout.py` CLI invocation and binary lookup: - Print usage and exit cleanly when invoked with `-h` or `--help` (exit code 0), and exit with code 2 on missing arguments, avoiding an unhandled `IndexError`. - Look up `xcl` executable via `XCL_EXE` environment variable, falling back to `target/release/xcl.exe` and `target/debug/xcl.exe`. - Provide informative stderr error messages when the specified directory or `xcl` binary is missing instead of throwing unhandled tracebacks. - Add `scripts/test_check_layout.py` covering CLI help flags, exit codes on missing arguments/directories/binaries, synthetic RTS0 layout parsing, and mock disassembly matching. **Tested** - `python -B -m unittest discover -s scripts -p "test_*.py" -v`: 16 passed, 0 failed. - Tested `scripts/re/check_layout.py --help` (exits 0 with usage docstring). - Tested `scripts/re/check_layout.py` with no args (exits 2 with usage docstring). - Tested `scripts/re/check_layout.py non_existent_dir` (exits 1 with clear diagnostic). - Validated PR description and changed files with `scripts/pr_check.py --local`. **Not tested** - Retail game smoke tests: this PR modifies only offline analysis scripts in `scripts/` and does not touch runtime code or dependencies. **AI use** Antigravity (Gemini 3.8 Flash (High)) designed the CLI argument handling and fallback resolution, implemented unit tests in `scripts/test_check_layout.py`, ran the test suite, and verified PR conventions.
DavidM1911 commented 2026-11-24 14:06:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T13:22:00Z.


Independent verification on current main 384f7f7 (branch already contains it — clean).

Machine: Windows 11, Ryzen 9 7900X; Python 3.

  • python scripts/test_check_layout.py: 7 tests OK — covers the hardened check_layout CLI argument handling and binary lookup.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

<!-- greyfinch-sync:ivall/xcl:comment:7132726969 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1196#issuecomment-7132726969). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T13:22:00Z. --- Independent verification on current `main` `384f7f7` (branch already contains it — clean). **Machine:** Windows 11, Ryzen 9 7900X; Python 3. - `python scripts/test_check_layout.py`: **7 tests OK** — covers the hardened `check_layout` CLI argument handling and binary lookup. AI use: test runs by Devin (Cognition, SWE-2); no code changes.
futurepro62 commented 2026-11-24 15:05:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:15:59Z.


Tested exact head 5d84245, script tests only, since this PR has no test report yet.

Tested

  • Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here).
  • python -m pytest scripts/test_check_layout.py at the head: 7 passed, 2 subtests passed.
  • The PR's test file against current main's script (930e8b4): does not get to run: collection fails with FileNotFoundError, since main's check_layout.py runs its scan at import time (which is what this PR changes).
  • #1088 also changes this loop (it stops the scan when xcl disasm exits non-zero); this PR does not check that exit code, and the two conflict (git merge-tree reports a conflict).

Not tested

  • PowerShell 7, the CI workflow itself, a game (no runtime code changed).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7134098481 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1196#issuecomment-7134098481). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:15:59Z. --- Tested exact head `5d84245`, script tests only, since this PR has no test report yet. **Tested** - Windows 11 Home 26300, Python 3.14.3 with pytest 9.0.3, Windows PowerShell 5.1.26100.9818 (no PowerShell 7 here). - `python -m pytest scripts/test_check_layout.py` at the head: 7 passed, 2 subtests passed. - The PR's test file against current main's script (`930e8b4`): does not get to run: collection fails with `FileNotFoundError`, since main's `check_layout.py` runs its scan at import time (which is what this PR changes). - #1088 also changes this loop (it stops the scan when `xcl disasm` exits non-zero); this PR does not check that exit code, and the two conflict (`git merge-tree` reports a conflict). **Not tested** - PowerShell 7, the CI workflow itself, a game (no runtime code changed). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
heditrigui commented 2026-11-24 15:06:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by heditrigui on 2026-11-24T14:55:55Z.


Thanks for the independent test verification @futurepro62! Good catch on #1088. If maintainers prefer to land #1088 first, we can rebase this PR on top of it to incorporate both the disasm returncode check from #1088 and the CLI argument handling, binary lookup resolution, and unit tests from #1196.

<!-- greyfinch-sync:ivall/xcl:comment:7135182578 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1196#issuecomment-7135182578). Originally posted by [heditrigui](https://github.com/heditrigui) on 2026-11-24T14:55:55Z. --- Thanks for the independent test verification @futurepro62! Good catch on #1088. If maintainers prefer to land #1088 first, we can rebase this PR on top of it to incorporate both the disasm returncode check from #1088 and the CLI argument handling, binary lookup resolution, and unit tests from #1196.
RavenCurseBurg commented 2026-11-26 02:08:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-26T01:38:41Z.


Tested 5d84245635be718805ab6dd012de8cd17c8571bf and the integration on top of this PR. The candidate carries the disassembly error handling from #1088 (d17e8d946753) and retains this PR’s executable selection.

With two synthetic RTS0 files and a command-line stand-in selected via XCL_EXE, I ran four failure cases: diagnostics on both streams, stderr only, stdout only, or neither. The current head called the stand-in twice and exited 0 in all four. The candidate stopped on the first shader and returned its exit code 23 in all four. It printed the filename, preferred stderr, used stdout when needed, and printed no successful load summary.

Four successful runs on each revision counted both loads. They covered an override path containing spaces, a release-only build, debug and release present together, and an override with both present. I checked which executable actually ran.

python -B -m unittest discover -s scripts -p "test_check_layout.py" on the candidate: 8 passed, 0 failed or skipped. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the integration and fixtures and ran the tests. No real disassembler, game, GPU or full Rust suite was exercised.

<!-- greyfinch-sync:ivall/xcl:comment:7179980018 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7179980018). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T01:38:41Z. --- Tested `5d84245635be718805ab6dd012de8cd17c8571bf` and [the integration on top of this PR](https://github.com/RavenCurseBurg/xcl/commit/313475de6e9fb47aca91d8451f408b918324d6e2). The candidate carries the disassembly error handling from #1088 (`d17e8d946753`) and retains this PR’s executable selection. With two synthetic RTS0 files and a command-line stand-in selected via `XCL_EXE`, I ran four failure cases: diagnostics on both streams, stderr only, stdout only, or neither. The current head called the stand-in twice and exited 0 in all four. The candidate stopped on the first shader and returned its exit code 23 in all four. It printed the filename, preferred stderr, used stdout when needed, and printed no successful load summary. Four successful runs on each revision counted both loads. They covered an override path containing spaces, a release-only build, debug and release present together, and an override with both present. I checked which executable actually ran. `python -B -m unittest discover -s scripts -p "test_check_layout.py"` on the candidate: 8 passed, 0 failed or skipped. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the integration and fixtures and ran the tests. No real disassembler, game, GPU or full Rust suite was exercised.
throny commented 2026-11-28 07:48:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T07:48:50Z.


Two contributors checked independently and found that #2151 solves the same problem in a different way: #1607, group D146. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7236178521 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7236178521). Originally posted by [throny](https://github.com/throny) on 2026-11-28T07:48:50Z. --- <!-- xcl-1607-hint:D146 --> Two contributors checked independently and found that #2151 solves the same problem in a different way: #1607, group D146. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Foniass commented 2026-12-01 05:03:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:03:56Z.


Triage (#1607) – head 5d84245

#2151 hardens the same script (scripts/re/check_layout.py) differently: it adds an --xcl flag, DXBC / RTS0 bounds validation and disassembler error handling, while this PR finds xcl through XCL_EXE and the debug/release target dirs and adds -h and exit codes. Both rewrite the same lines, so only one can merge as is.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301385779 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7301385779). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:03:56Z. --- **Triage (#1607)** – head 5d84245 #2151 hardens the same script (scripts/re/check_layout.py) differently: it adds an `--xcl` flag, DXBC / RTS0 bounds validation and disassembler error handling, while this PR finds xcl through `XCL_EXE` and the debug/release target dirs and adds `-h` and exit codes. Both rewrite the same lines, so only one can merge as is. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-02 09:22:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-02T09:22:14Z.


Two contributors checked independently and found that #1729 #2151 solves the same problem in a different way: #1607, group D237. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7340785976 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7340785976). Originally posted by [throny](https://github.com/throny) on 2026-12-02T09:22:14Z. --- <!-- xcl-1607-hint:D237 --> Two contributors checked independently and found that #1729 #2151 solves the same problem in a different way: #1607, group D237. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1196:upstream-pr/1196'
git switch 'upstream-pr/1196'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1196'
git switch 'upstream-pr/1196'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1196'
git switch 'upstream-pr/1196'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1196'
git switch 'main'
git merge --squash 'upstream-pr/1196'
git switch 'main'
git merge --ff-only 'upstream-pr/1196'
git switch 'main'
git merge 'upstream-pr/1196'
git push origin 'main'
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
xcl-dev/xcl!1187
No description provided.