tooling: extract main(argv) and add dest path and subprocess error guards in fetch_addrlib with CLI suite #2592

Merged
Ammmae0x merged 1 commit from upstream-pr/2600 into main 2026-11-25 22:46:47 +00:00
Ammmae0x commented 2026-11-25 22:42:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T22:42:29Z.


Summary

  • Refactor tools/fetch_addrlib.py:main(argv=None) -> int (raise SystemExit(main()) under __main__) so the CLI entry point accepts explicit argv and returns an integer status cleanly.
  • Validate upfront that --dest is not an existing non-directory file (dest.exists() and not dest.is_dir()), check emptiness deterministically via sorted(dest.iterdir()), and catch (OSError, ValueError, subprocess.SubprocessError) via parser.exit(1, f"fetch_addrlib: {exc}\n") while preserving non-empty, dirty-checkout, remote-mismatch, commit-mismatch, and missing-header refusals with zero raw tracebacks.
  • Add offline pure-Python mocked-git CLI/error/mutation suite tests/fetch_addrlib_cli_check.py and register tooling_fetch_addrlib_cli_check (TIMEOUT 60) in CMakeLists.txt.

Verification

  • python -B tests/fetch_addrlib_cli_check.py -v -> Ran 6 tests in 0.618s (OK, exit 0)
  • Adversarial temp-copy mutation check (15 mutations across non-directory guard, origin check, pre/post clean checks, non-empty check, commit check, header check, OSError/ValueError/SubprocessError handlers, exit code, stderr prefix, argv forwarding, main() return type, and __main__ exit propagation) -> 15/15 KILLED
  • python -B tests/form_coverage_check.py -> form coverage checks passed (exit 0)
  • python -B tests/docs_links_check.py -> Self-test passed. Checked 19 Markdown files and 499 links. (exit 0)
  • python -B tests/bidi_controls_check.py -> Self-test passed. Checked 1832 tracked source, script and build/CI files: no bidirectional controls. (exit 0)

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6615249785 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2600). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T22:42:29Z. --- ## Summary - Refactor `tools/fetch_addrlib.py:main(argv=None) -> int` (`raise SystemExit(main())` under `__main__`) so the CLI entry point accepts explicit `argv` and returns an integer status cleanly. - Validate upfront that `--dest` is not an existing non-directory file (`dest.exists() and not dest.is_dir()`), check emptiness deterministically via `sorted(dest.iterdir())`, and catch `(OSError, ValueError, subprocess.SubprocessError)` via `parser.exit(1, f"fetch_addrlib: {exc}\n")` while preserving non-empty, dirty-checkout, remote-mismatch, commit-mismatch, and missing-header refusals with zero raw tracebacks. - Add offline pure-Python mocked-git CLI/error/mutation suite `tests/fetch_addrlib_cli_check.py` and register `tooling_fetch_addrlib_cli_check` (`TIMEOUT 60`) in `CMakeLists.txt`. ## Verification - `python -B tests/fetch_addrlib_cli_check.py -v` -> `Ran 6 tests in 0.618s` (`OK`, exit 0) - Adversarial temp-copy mutation check (15 mutations across non-directory guard, origin check, pre/post clean checks, non-empty check, commit check, header check, `OSError`/`ValueError`/`SubprocessError` handlers, exit code, stderr prefix, `argv` forwarding, `main()` return type, and `__main__` exit propagation) -> `15/15 KILLED` - `python -B tests/form_coverage_check.py` -> `form coverage checks passed` (exit 0) - `python -B tests/docs_links_check.py` -> `Self-test passed. Checked 19 Markdown files and 499 links.` (exit 0) - `python -B tests/bidi_controls_check.py` -> `Self-test passed. Checked 1832 tracked source, script and build/CI files: no bidirectional controls.` (exit 0) AI-assisted.
upstream-sync closed this pull request 2026-11-25 23:02:00 +00:00
tedin7 commented 2026-11-25 23:02:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T22:46:32Z.

Review: COMMENTED


Review of head 550359d9 against origin/main. No blocking findings.

What I checked

  • main(argv=None) -> int and raise SystemExit(main()): correct, success returns 0.
  • --dest pointing at an existing file is refused with exit 1 and a one-line message. OSError, ValueError and SubprocessError now give exit 1 with no traceback. The sys.exit refusals (non-empty dest, dirty checkout, wrong remote, commit mismatch, missing header) still behave as before.
  • The new test tests/fetch_addrlib_cli_check.py is offline (mocked git) and is registered in CMake next to the other INTAKE_PYTHON tests. No sibling callers of fetch_addrlib.main exist.
  • I did not find another open or merged PR covering this slice.

Commands run (Linux)

  • python3 -B tests/fetch_addrlib_cli_check.py -> Ran 6 tests, OK
  • python3 tests/docs_links_check.py -> 19 files, 499 links, ok
  • python3 tests/bidi_controls_check.py -> no bidirectional controls
  • git diff --check origin/main...HEAD -> clean
  • Mutations, each made the suite fail: commit check disabled (1 failure), SubprocessError dropped from the handler (2 errors), error exit code 1 changed to 0 (6 failures)

Windows dev+release verification follows in a separate receipt comment.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6066027915 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2600#pullrequestreview-6066027915). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T22:46:32Z. **Review:** COMMENTED --- Review of head 550359d9 against origin/main. No blocking findings. What I checked - `main(argv=None) -> int` and `raise SystemExit(main())`: correct, success returns 0. - `--dest` pointing at an existing file is refused with exit 1 and a one-line message. OSError, ValueError and SubprocessError now give exit 1 with no traceback. The sys.exit refusals (non-empty dest, dirty checkout, wrong remote, commit mismatch, missing header) still behave as before. - The new test `tests/fetch_addrlib_cli_check.py` is offline (mocked git) and is registered in CMake next to the other INTAKE_PYTHON tests. No sibling callers of `fetch_addrlib.main` exist. - I did not find another open or merged PR covering this slice. Commands run (Linux) - `python3 -B tests/fetch_addrlib_cli_check.py` -> Ran 6 tests, OK - `python3 tests/docs_links_check.py` -> 19 files, 499 links, ok - `python3 tests/bidi_controls_check.py` -> no bidirectional controls - `git diff --check origin/main...HEAD` -> clean - Mutations, each made the suite fail: commit check disabled (1 failure), SubprocessError dropped from the handler (2 errors), error exit code 1 changed to 0 (6 failures) Windows dev+release verification follows in a separate receipt comment. AI-assisted; commands listed were executed locally.
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
R0Y00/Xbox2Windows!2592
No description provided.