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

Open
github-bot wants to merge 1 commit from github-bot/gh-1196 into main AGit
Owner

@⁠heditrigui on GitHub · 2026-11-24 13:05 UTC · original
heditrigui:scripts/check-layout-cli-hardening → main · +206 −29 · 2 files · 1 commits · open

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.

**@⁠heditrigui** on GitHub · 2026-11-24 13:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1196) `heditrigui:scripts/check-layout-cli-hardening` → `main` · +206 −29 · 2 files · 1 commits · open 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:46:44 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 13:22 UTC · original

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.

**@⁠DavidM1911** on GitHub · 2026-11-24 13:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7132726969) 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.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 14:15 UTC · original

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.
**@⁠futurepro62** on GitHub · 2026-11-24 14:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7134098481) 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.
Author
Owner

@⁠heditrigui on GitHub · 2026-11-24 14:55 UTC · original

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.

**@⁠heditrigui** on GitHub · 2026-11-24 14:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7135182578) 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.
Author
Owner

@⁠RavenCurseBurg on GitHub · 2026-11-26 01:38 UTC · original · edited 2026-11-26 01:52 UTC

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.

**@⁠RavenCurseBurg** on GitHub · 2026-11-26 01:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1196#issuecomment-7179980018) · edited 2026-11-26 01:52 UTC 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1196/head:github-bot/gh-1196'
git switch 'github-bot/gh-1196'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1196'
git switch 'github-bot/gh-1196'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1196'
git switch 'github-bot/gh-1196'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1196'
git switch 'main'
git merge --squash 'github-bot/gh-1196'
git switch 'main'
git merge --ff-only 'github-bot/gh-1196'
git switch 'main'
git merge 'github-bot/gh-1196'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.