Scripts: harden record_writers CLI argument handling and validation #2049
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!2049
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2049"
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-25 02:00 UTC · original
heditrigui:scripts/record-writers-cli-hardening→main· +246 −62 · 2 files · 1 commits · openSummary
Hardens CLI argument handling and validation in
scripts/re/record_writers.pyand expands unit test coverage inscripts/test_record_writers.py:-hand--helpCLI option support with usage docstrings and clean exit code 0.error: file not found: '<asm_path>'on stderr and exits code 1) instead of crashing with unhandled Python exceptions.find_record_writers(lines),dump_record_writers(lines, file=None), andmain(argv=None, out=None)functions so the module can be cleanly imported without executing top-level logic or crashing.scripts/test_record_writers.pyfrom 1 to 9 tests covering branch targets with/without hex prefix, list-field header extraction, lea length calculation, empty listings, help flags, missing argument exit codes, nonexistent files, direct Python API usage, and programmaticmaininvocation.Tested
python scripts/test_record_writers.py(9 tests passed in 0.92s).python -m pytest scripts/(33 passed in 1.31s).scripts/pr_check.py --local.Not tested
scripts/tools are non-runtime code).AI use
@raylitebull on GitHub · 2026-11-25 02:04 UTC · original
Code review on
48c08bc:find_record_writers/dump_record_writers/maininscripts/re/record_writers.pycleanly adds-h/--help(rc=0), missing-arg usage (rc=2), missing-file handling (rc=1), and comprehensive CLI + unit tests inscripts/test_record_writers.py.CIworkflow approved (running).Remaining before merge:
Build and testfinishing green plus independent verification on48c08bc.@JJAutoCompare on GitHub · 2026-11-25 02:12 UTC · original
Independent Windows compatibility run for
48c08bc26023dcbbece3e1bd3906b083d6917a3e. The reused checkout was clean before and after the run, and the open PR still pointed to this commit after testing.Tested
maincalls, branch targets with and without0x, immediate and list-field headers,addandlealengths, and a listing with zero matching sites.imm beef, 40 bytes, bound+0x30, fallback slot 7), and left stderr empty. The missing path exited 1, left stdout empty, and wrote exactly one file-not-found message to stderr with the original path.Commands executed from the repository root (
TMPandTEMPwere onL:):Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 04:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@RavenCurseBurg on GitHub · 2026-11-25 21:38 UTC · original · edited 2026-11-25 21:45 UTC
On
48c08bc26023dcbbece3e1bd3906b083d6917a3eI redirected the same seven-line synthetic listing withcmd /d /c type source.txt > sample.asmfrom each shell, then ranpython -B scripts/re/record_writers.py sample.asm. Windows PowerShell 5.1 wrote UTF-16LE (first bytesFF FE 20 00), and the CLI exited 0 reporting 0 sites. PowerShell 7.6.9 wrote the original bytes and the CLI reported the expected single site.Fix and regression test. Both redirected files now produce the same header, 32-byte record and fallback slot 8. I also passed both files in one invocation with a missing filename between them. Both valid files were processed, stderr identified the missing file, and the CLI exited 1.
python -B -m unittest discover -s scripts -p "test_*.py"passed all 33 tests on Windows 11 26100.9711, i7-13700, Python 3.14.3. The focused suite passed all 9 tests. The new encoding checks failed on the original code for UTF-8 with BOM and both UTF-16 byte orders when the first line contained the matching instruction. Synthetic text only. OpenAI Codex (GPT-6) prepared the patch, ran the checks and wrote this report.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.