Scripts: harden gen_gdk_table CLI argument handling and output option #1267
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1267
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1267"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@heditrigui on GitHub · 2026-11-24 13:59 UTC · original
heditrigui:scripts/gen-gdk-table-cli-hardening→main· +172 −16 · 2 files · 1 commits · openHarden
scripts/gen_gdk_table.pyargument parsing and output configuration:-hand--helpflags, printing the script's docstring usage and exiting with code 0.IndexError.sys.stderrwhen the file is missing or contains no matching GDK API table rows (exit code 1) instead of crashing with unhandled tracebacks.[out_rs]to write output to a custom destination instead of strictly hardcodingcrates/xcl/src/hle/xgameruntime/gdk_table.rs.scripts/test_gen_gdk_table.pycovering CLI help, missing argument handling, invalid file reporting, custom output path writing, and table sorting/hex formatting.Tested
python -B -m unittest discover -s scripts -p "test_*.py" -v: 17 passed, 0 failed.scripts/gen_gdk_table.py --help(exits 0 with usage docstring).scripts/gen_gdk_table.pywith no args (exits 2 with usage docstring).scripts/gen_gdk_table.py nonexistent.txt(exits 1 with clear diagnostic).scripts/pr_check.py --local.Not tested
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_gdk_table.py, ran the test suite, and verified PR conventions.@DavidM1911 on GitHub · 2026-11-24 14:05 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Thanks!
@RavenCurseBurg on GitHub · 2026-11-25 14:35 UTC · original · edited 2026-11-26 06:44 UTC
Tested
4859ec4bb5cb819eb477ee46e332235380e4ca00withpython -B scripts/gen_gdk_table.py <input> <output>from a different working directory. With the three-row synthetic table, a Unicode directory and a spaced output name worked. Two runs produced byte-identical LF output with the slots in numeric order. The default repository table remained unchanged. The fixture used UTF-8 subprocess I/O.The eight original generator tests passed. Three additional CLI cases exited 1 with a Python traceback: invalid UTF-8 input, an existing directory used as the output filename, and a regular file used as the output’s parent. A text input with no rows already gave a concise error.
Fix and regression tests. The three new failure cases reproduced on the PR head. After the change all three gave path-specific stderr diagnostics and exit 1, and invalid input preserved the previous output bytes.
python -B -m unittest discover -s scripts -p "test_*.py"passed all 19 tests.Windows 11 26100.9711, i7-13700, RTX 4060, Python 3.14.3. No proprietary GDK input, Rust build, retail title or GPU workload. OpenAI Codex (GPT-6) ran the checks, prepared the patch and wrote this report.
Follow-up on the latest review
I reproduced review 6068893182 on the PR head. With a valid one-row synthetic input and an existing output file, adding one extra argument returned 0 and overwrote the file.
The candidate checks arity before opening either path. The same command now exits 2 and preserves every byte. Both supported invocations (explicit and default output) still generated identical Rust tables in an isolated directory. The full Python script discovery run passed all 18 tests, including the new regression.
Candidate commit 2cf7b91f is based directly on
4859ec4bb5cb. Reproduce withpython -B -m unittest discover -s scripts -p test_*.py. OpenAI Codex (GPT-6) prepared the fix and ran these Windows CPU fixtures. No game, GPU benchmark or workspace build.@luckyteagirl on GitHub · 2026-11-26 05:15 UTC · original · reviewed
Could
mainreject surplus positional arguments before opening the output? The new usage lists one required input and one optional output, butgen_gdk_table.py table.txt existing.rs unexpectedtakesargs[1], ignoresargs[2], and overwritesexisting.rsas if the invocation were valid. A CLI fixture with a sentinel output could check for a usage error and unchanged bytes. Source review only at head4859ec4b; I did not run the script. AI-assisted with Codex (GPT-6.2 Sol).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.