runtime: harden startup triage_run CLI guards and add CLI suite #2664

Merged
Ammmae0x merged 1 commit from upstream-pr/2672 into main 2026-11-26 02:48:13 +00:00
Ammmae0x commented 2026-11-26 01:40:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-26T01:40:24Z.


Change

Harden CLI argument validation and error reporting in tools/startup/triage_run.py and add a pure-Python synthetic log/cache CLI suite (tests/startup_triage_run_cli_check.py), registered in CMakeLists.txt as runtime_startup_triage_run_cli_check.

  • Validate upfront in _validate_args() that logdir exists and is a regular file or directory, that --shader-cache (when given) exists and is a directory (not a regular file), and that --max-items >= 1.
  • Catch (OSError, ValueError) in main(argv=None) -> int to emit a clean stderr error message and return exit code 1 with zero raw tracebacks, and update __main__ to raise SystemExit(main()).
  • Preserve existing triage_run() library behavior and tests/startup_triage_run_check.py unchanged.

Verification

Verified on commit 01446247 (based on upstream/main 82c70807) on Windows using out/pe-env/Scripts/python.exe -B:

  • out\pe-env\Scripts\python.exe -B tests\startup_triage_run_check.py -> exit 0 (startup triage_run checks: 0 failed).
  • out\pe-env\Scripts\python.exe -B tests\startup_triage_run_cli_check.py -> exit 0 (8/8 tests OK, 0 skips: directory and single-file logdir, --shader-cache summary, --max-items truncation, argv=None / __main__, missing/non-regular logdir, missing/file --shader-cache, --max-items <= 0, runtime OSError/ValueError exit 1 without traceback, Python 3.14-safe argparse checks, and 5 fast in-memory guard mutations).
  • out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py -> exit 0.
  • out\pe-env\Scripts\python.exe -B tests\docs_links_check.py -> exit 0.
  • out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py -> exit 0.
  • On-disk spot-mutation negative controls (3/3 killed by tests/startup_triage_run_cli_check.py): disabling logdir.exists() guard, disabling shader_cache.is_dir() guard, and relaxing max_items < 1 to < 0.

Evidence and follow-up

  • Pure-Python synthetic log and shader-cache fixtures generated at runtime in temporary directories (no game files, dumps, or private paths; MIT License).
  • No external tools or GPU hardware required.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6617564944 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2672). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-26T01:40:24Z. --- ## Change Harden CLI argument validation and error reporting in `tools/startup/triage_run.py` and add a pure-Python synthetic log/cache CLI suite (`tests/startup_triage_run_cli_check.py`), registered in `CMakeLists.txt` as `runtime_startup_triage_run_cli_check`. - Validate upfront in `_validate_args()` that `logdir` exists and is a regular file or directory, that `--shader-cache` (when given) exists and is a directory (not a regular file), and that `--max-items >= 1`. - Catch `(OSError, ValueError)` in `main(argv=None) -> int` to emit a clean stderr error message and return exit code `1` with zero raw tracebacks, and update `__main__` to `raise SystemExit(main())`. - Preserve existing `triage_run()` library behavior and `tests/startup_triage_run_check.py` unchanged. ## Verification Verified on commit `01446247` (based on `upstream/main` `82c70807`) on Windows using `out/pe-env/Scripts/python.exe -B`: - `out\pe-env\Scripts\python.exe -B tests\startup_triage_run_check.py` -> exit 0 (`startup triage_run checks: 0 failed`). - `out\pe-env\Scripts\python.exe -B tests\startup_triage_run_cli_check.py` -> exit 0 (8/8 tests OK, 0 skips: directory and single-file `logdir`, `--shader-cache` summary, `--max-items` truncation, `argv=None` / `__main__`, missing/non-regular `logdir`, missing/file `--shader-cache`, `--max-items <= 0`, runtime `OSError`/`ValueError` exit 1 without traceback, Python 3.14-safe argparse checks, and 5 fast in-memory guard mutations). - `out\pe-env\Scripts\python.exe -B tests\form_coverage_check.py` -> exit 0. - `out\pe-env\Scripts\python.exe -B tests\docs_links_check.py` -> exit 0. - `out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py` -> exit 0. - On-disk spot-mutation negative controls (3/3 killed by `tests/startup_triage_run_cli_check.py`): disabling `logdir.exists()` guard, disabling `shader_cache.is_dir()` guard, and relaxing `max_items < 1` to `< 0`. ## Evidence and follow-up - Pure-Python synthetic log and shader-cache fixtures generated at runtime in temporary directories (no game files, dumps, or private paths; MIT License). - No external tools or GPU hardware required. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-26 03:03:08 +00:00
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!2664
No description provided.