Scripts: harden gen_bcpack_victory_tables CLI argument handling and output option #1440

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

@⁠heditrigui on GitHub · 2026-11-24 15:59 UTC · original
heditrigui:scripts/gen-bcpack-victory-tables-cli-hardening → main · +171 −7 · 2 files · 1 commits · open

Harden scripts/gen_bcpack_victory_tables.py argument parsing and output configuration:

  • Support -h and --help flags, printing the script's docstring usage and exiting with code 0.
  • Print usage and exit with code 2 when invoked without arguments, avoiding an unhandled IndexError.
  • Validate input file existence and report diagnostic errors to sys.stderr when <bcpack-tables.bin> is missing or has an unexpected size (exit code 1) instead of crashing with unhandled tracebacks.
  • Accept an optional second argument [out.rs] to write output to a custom destination, defaulting to crates/xcl/src/hle/bcpack/tables.rs.
  • Add scripts/test_gen_bcpack_victory_tables.py covering CLI help, missing argument handling, invalid file reporting, custom output path writing, and synthetic table binary parsing.

Tested

  • python -B -m unittest discover -s scripts -p "test_*.py" -v: 23 passed, 0 failed.
  • Tested scripts/gen_bcpack_victory_tables.py --help (exits 0 with usage docstring).
  • Tested scripts/gen_bcpack_victory_tables.py with no args (exits 2 with usage docstring).
  • Tested scripts/gen_bcpack_victory_tables.py nonexistent.bin (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 code generator tooling in scripts/ and does not touch runtime code or dependencies.

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

**@⁠heditrigui** on GitHub · 2026-11-24 15:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1440) `heditrigui:scripts/gen-bcpack-victory-tables-cli-hardening` → `main` · +171 −7 · 2 files · 1 commits · open Harden `scripts/gen_bcpack_victory_tables.py` argument parsing and output configuration: - Support `-h` and `--help` flags, printing the script's docstring usage and exiting with code 0. - Print usage and exit with code 2 when invoked without arguments, avoiding an unhandled `IndexError`. - Validate input file existence and report diagnostic errors to `sys.stderr` when `<bcpack-tables.bin>` is missing or has an unexpected size (exit code 1) instead of crashing with unhandled tracebacks. - Accept an optional second argument `[out.rs]` to write output to a custom destination, defaulting to `crates/xcl/src/hle/bcpack/tables.rs`. - Add `scripts/test_gen_bcpack_victory_tables.py` covering CLI help, missing argument handling, invalid file reporting, custom output path writing, and synthetic table binary parsing. **Tested** - `python -B -m unittest discover -s scripts -p "test_*.py" -v`: 23 passed, 0 failed. - Tested `scripts/gen_bcpack_victory_tables.py --help` (exits 0 with usage docstring). - Tested `scripts/gen_bcpack_victory_tables.py` with no args (exits 2 with usage docstring). - Tested `scripts/gen_bcpack_victory_tables.py nonexistent.bin` (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 code generator tooling in `scripts/` and does not touch runtime code or dependencies. **AI use** Antigravity (Gemini 3.8 Flash (High)) designed the CLI argument handling and optional output destination, implemented unit tests in `scripts/test_gen_bcpack_victory_tables.py`, ran the test suite, and verified PR conventions.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:55 +00:00
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-24 16:08 UTC · original

Windows CLI test report for ab7a400

Tested

  • Windows 11 25H2 (build 26200), Python 3.14.5 x64. python -B -m unittest discover -s scripts -p "test_*.py" -v passed 23 tests on clean head ab7a400c70bb334fac520c8bcc50573c19d4ddb4.
  • I ran the CLI from a separate working directory using python -I. For two 77,982-byte synthetic inputs (zero-filled and seeded), the explicit output from the parent commit 037aecd57e8a2ae55154d5e0dfb7119e75430f5b, the PR’s explicit output, and the PR’s default output were byte-for-byte identical. The explicit PR path included spaces and a new subdirectory. I tested the default destination in a temporary copy.
  • With no arguments, the parent raised IndexError; the PR printed usage and exited 2. Both -h and --help printed usage and exited 0 on the PR.
  • The PR reported exit 1 without a traceback for a missing file and for 0-, 77,981-, and 77,983-byte inputs. Those cases left an existing default output byte-for-byte intact and created no file at a new explicit destination.

Not tested

  • Real table data and retail-title smoke testing. The checks above used synthetic data and the Python tooling suite.

AI use

  • OpenAI Codex (GPT-6, exact model variant unavailable) ran the tests and prepared this report.
**@⁠nnonno91** on GitHub · 2026-11-24 16:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/1440#issuecomment-7137175735) ### Windows CLI test report for `ab7a400` **Tested** - Windows 11 25H2 (build 26200), Python 3.14.5 x64. `python -B -m unittest discover -s scripts -p "test_*.py" -v` passed **23 tests** on clean head `ab7a400c70bb334fac520c8bcc50573c19d4ddb4`. - I ran the CLI from a separate working directory using `python -I`. For two 77,982-byte synthetic inputs (zero-filled and seeded), the explicit output from the parent commit `037aecd57e8a2ae55154d5e0dfb7119e75430f5b`, the PR’s explicit output, and the PR’s default output were byte-for-byte identical. The explicit PR path included spaces and a new subdirectory. I tested the default destination in a temporary copy. - With no arguments, the parent raised `IndexError`; the PR printed usage and exited `2`. Both `-h` and `--help` printed usage and exited `0` on the PR. - The PR reported exit `1` without a traceback for a missing file and for 0-, 77,981-, and 77,983-byte inputs. Those cases left an existing default output byte-for-byte intact and created no file at a new explicit destination. **Not tested** - Real table data and retail-title smoke testing. The checks above used synthetic data and the Python tooling suite. **AI use** - OpenAI Codex (GPT-6, exact model variant unavailable) ran the tests and prepared this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 18:52 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 18:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1440#issuecomment-7141274782) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠RavenCurseBurg on GitHub · 2026-11-25 16:12 UTC · original

I reproduced the extra-argument issue reported above on ab7a400c70bb334fac520c8bcc50573c19d4ddb4. With a 77,982-byte synthetic table, python -I scripts/gen_bcpack_victory_tables.py input.bin output.rs extra returned 0 and replaced an existing 15-byte output with 258,080 bytes.

Fix and CLI regression test. The generator now rejects the extra positional argument before opening the destination, writes the diagnostic to stderr and exits 2. The test starts with a sentinel output and checks its exact bytes. It failed before the fix (exit 0) and passed after. All 24 Python script tests passed with python -B -m unittest discover -s scripts -p "test_*.py"; git diff --check also passed.

Windows 11 26100.9711, i7-13700, RTX 4060, Python 3.14.3. Synthetic table data only; no game, Rust or GPU run. OpenAI Codex (GPT-6) wrote the patch and ran the checks.

**@⁠RavenCurseBurg** on GitHub · 2026-11-25 16:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1440#issuecomment-7167690327) I reproduced the extra-argument issue reported above on `ab7a400c70bb334fac520c8bcc50573c19d4ddb4`. With a 77,982-byte synthetic table, `python -I scripts/gen_bcpack_victory_tables.py input.bin output.rs extra` returned 0 and replaced an existing 15-byte output with 258,080 bytes. [Fix and CLI regression test](https://github.com/RavenCurseBurg/xcl/commit/fe18c0b10c260af6506846d5c15f6c4a3a25d92b). The generator now rejects the extra positional argument before opening the destination, writes the diagnostic to stderr and exits 2. The test starts with a sentinel output and checks its exact bytes. It failed before the fix (exit 0) and passed after. All 24 Python script tests passed with `python -B -m unittest discover -s scripts -p "test_*.py"`; `git diff --check` also passed. Windows 11 26100.9711, i7-13700, RTX 4060, Python 3.14.3. Synthetic table data only; no game, Rust or GPU run. OpenAI Codex (GPT-6) wrote the patch and ran the checks.
@ -149,0 +159,4 @@
def main(argv=None):
args = argv if argv is not None else sys.argv[1:]
Author
Owner

@⁠gut0to on GitHub · 2026-11-24 17:06 UTC · original

The documented usage accepts an input file and at most one optional output path, but main never rejects arguments after args[1]. A command with an extra positional argument silently ignores it and exits successfully, which can hide a typo. Please reject unexpected arguments and add a CLI test. AI-assisted review; I checked the documented usage against the argument handling.

**@⁠gut0to** on GitHub · 2026-11-24 17:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1440#discussion_r4683658652) The documented usage accepts an input file and at most one optional output path, but `main` never rejects arguments after `args[1]`. A command with an extra positional argument silently ignores it and exits successfully, which can hide a typo. Please reject unexpected arguments and add a CLI test. AI-assisted review; I checked the documented usage against the argument handling.
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/1440/head:github-bot/gh-1440'
git switch 'github-bot/gh-1440'

Merge

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