runtime: add main(argv), csv.Error/directory guards, and CLI suite in startup_audio_timeline #2432

Merged
Ammmae0x merged 2 commits from upstream-pr/2440 into main 2026-11-25 19:40:55 +00:00
Ammmae0x commented 2026-11-25 16:52:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T16:52:46Z.


Change

Add a testable main(argv=None) -> int entrypoint, upfront directory guards for packets and inputs, and csv.Error handling to tools/startup_audio_timeline.py, together with a standalone pure-Python CLI test suite registered in CMakeLists.txt (startup_audio_timeline_cli_check).

  • tools/startup_audio_timeline.py:
    • Accept argv: list[str] | None = None in main, forward argv to parser.parse_args(argv), return 0 on success, and invoke raise SystemExit(main()) under __main__.
    • Reject directory paths for packets (args.packets.is_dir()) and inputs (args.inputs.is_dir()) before reading files.
    • Guard (OSError, ValueError, csv.Error) via parser.error(str(error)), preserving exit status 2 and the error reporting expected by tests/startup_audio_timeline_check.py with zero raw tracebacks while preserving exact JSON stdout schema.
  • tests/startup_audio_timeline_cli_check.py: standalone unittest suite using synthetic UTF-8-BOM CSV packet files and JSONL input events covering repeatable --action, custom --sample-rate/--before/--after, flags & 4 skip, zero-coverage silence windows, main(None) / __main__ forwarding, and negative/mutation controls (missing/directory packets and inputs, NUL-byte and field-limit csv.Error, non-UTF-8 inputs, malformed/non-object JSONL rows, NaN/Inf values, and zero-length/negative window bounds).
  • CMakeLists.txt: register startup_audio_timeline_cli_check immediately after startup_audio_timeline (tests/startup_audio_timeline_check.py left untouched).

Verification

Verified on rebased commit 1e9ccd5e (based on upstream/main e06aca8b) using out/pe-env/Scripts/python.exe -B:

  • out/pe-env/Scripts/python.exe -B tests/startup_audio_timeline_cli_check.py -v -> Ran 5 tests, OK (exit 0).
  • out/pe-env/Scripts/python.exe -B tests/startup_audio_timeline_check.py -v -> Ran 3 tests, OK (exit 0).
  • out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py -> form coverage checks passed (exit 0).
  • out/pe-env/Scripts/python.exe -B tests/docs_links_check.py -> Self-test passed. (exit 0).
  • out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py -> Self-test passed. (exit 0).
  • Spot mutation audit on tools/startup_audio_timeline.py: 8/8 mutations killed (argv forwarding, packets.is_dir(), inputs.is_dir(), csv.Error guard, OSError guard, zero-length window check, flags & 4 skip, integer 0 return).

Evidence and follow-up

All CSV and JSONL fixtures in tests/startup_audio_timeline_cli_check.py are synthetic byte arrays generated in-memory under the repository MIT license; no external binaries or game files are used. Contributors can run the suite directly via out/pe-env/Scripts/python.exe -B tests/startup_audio_timeline_cli_check.py or through CTest (startup_audio_timeline_cli_check).

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:6609370659 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2440). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T16:52:46Z. --- ## Change Add a testable `main(argv=None) -> int` entrypoint, upfront directory guards for `packets` and `inputs`, and `csv.Error` handling to `tools/startup_audio_timeline.py`, together with a standalone pure-Python CLI test suite registered in `CMakeLists.txt` (`startup_audio_timeline_cli_check`). - `tools/startup_audio_timeline.py`: - Accept `argv: list[str] | None = None` in `main`, forward `argv` to `parser.parse_args(argv)`, return `0` on success, and invoke `raise SystemExit(main())` under `__main__`. - Reject directory paths for `packets` (`args.packets.is_dir()`) and `inputs` (`args.inputs.is_dir()`) before reading files. - Guard `(OSError, ValueError, csv.Error)` via `parser.error(str(error))`, preserving exit status `2` and the error reporting expected by `tests/startup_audio_timeline_check.py` with zero raw tracebacks while preserving exact JSON stdout schema. - `tests/startup_audio_timeline_cli_check.py`: standalone unittest suite using synthetic UTF-8-BOM CSV packet files and JSONL input events covering repeatable `--action`, custom `--sample-rate`/`--before`/`--after`, `flags & 4` skip, zero-coverage silence windows, `main(None)` / `__main__` forwarding, and negative/mutation controls (missing/directory `packets` and `inputs`, NUL-byte and field-limit `csv.Error`, non-UTF-8 inputs, malformed/non-object JSONL rows, NaN/Inf values, and zero-length/negative window bounds). - `CMakeLists.txt`: register `startup_audio_timeline_cli_check` immediately after `startup_audio_timeline` (`tests/startup_audio_timeline_check.py` left untouched). ## Verification Verified on rebased commit `1e9ccd5e` (based on `upstream/main` `e06aca8b`) using `out/pe-env/Scripts/python.exe -B`: - `out/pe-env/Scripts/python.exe -B tests/startup_audio_timeline_cli_check.py -v` -> `Ran 5 tests`, `OK` (exit 0). - `out/pe-env/Scripts/python.exe -B tests/startup_audio_timeline_check.py -v` -> `Ran 3 tests`, `OK` (exit 0). - `out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py` -> `form coverage checks passed` (exit 0). - `out/pe-env/Scripts/python.exe -B tests/docs_links_check.py` -> `Self-test passed.` (exit 0). - `out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py` -> `Self-test passed.` (exit 0). - Spot mutation audit on `tools/startup_audio_timeline.py`: 8/8 mutations killed (`argv` forwarding, `packets.is_dir()`, `inputs.is_dir()`, `csv.Error` guard, `OSError` guard, zero-length window check, `flags & 4` skip, integer `0` return). ## Evidence and follow-up All CSV and JSONL fixtures in `tests/startup_audio_timeline_cli_check.py` are synthetic byte arrays generated in-memory under the repository MIT license; no external binaries or game files are used. Contributors can run the suite directly via `out/pe-env/Scripts/python.exe -B tests/startup_audio_timeline_cli_check.py` or through CTest (`startup_audio_timeline_cli_check`). ## 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.
tedin7 commented 2026-11-25 19:03:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:24:57Z.

Review: COMMENTED


Review of head 1e9ccd5e (comment only, no Windows run from me).

Checked:

  • tools/startup_audio_timeline.py: main(argv) forwards to parse_args(argv) and returns 0. The __main__ path uses raise SystemExit(main()). csv is already imported, and csv.Error is now caught, so a bad CSV exits 2 through parser.error instead of a traceback. The JSON output is unchanged.
  • CMakeLists.txt: the new test is registered right after startup_audio_timeline. It is pure Python, so no WARP or hardware run is needed. The author's body lists Windows python -B runs on this head, and the PR checks are green. I did not re-run those.
  • Overlap: #1870 (merged) only registered the existing check. I found no other open PR covering this CLI.

Commands run (Linux):

  • python3 -B tests/startup_audio_timeline_cli_check.py: 5 tests OK
  • python3 -B tests/startup_audio_timeline_check.py: OK
  • git diff --check origin/main...HEAD: clean
  • python3 tests/bidi_controls_check.py: pass
  • Mutation 1: remove csv.Error from the except tuple. The new suite fails.
  • Mutation 2: disable both is_dir() guards. The new suite fails.
  • Both mutations reverted with git checkout -- ..

Non-blocking note: on Linux and Windows, opening a directory already raises an OSError (IsADirectoryError / PermissionError), which the existing except turns into exit 2. So the is_dir() guards only change the message text. If you want less code, you could drop them and keep the test on the exit code. Fine to keep as is.

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6062841730 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2440#pullrequestreview-6062841730). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:24:57Z. **Review:** COMMENTED --- Review of head `1e9ccd5e` (comment only, no Windows run from me). Checked: - `tools/startup_audio_timeline.py`: `main(argv)` forwards to `parse_args(argv)` and returns 0. The `__main__` path uses `raise SystemExit(main())`. `csv` is already imported, and `csv.Error` is now caught, so a bad CSV exits 2 through `parser.error` instead of a traceback. The JSON output is unchanged. - `CMakeLists.txt`: the new test is registered right after `startup_audio_timeline`. It is pure Python, so no WARP or hardware run is needed. The author's body lists Windows `python -B` runs on this head, and the PR checks are green. I did not re-run those. - Overlap: #1870 (merged) only registered the existing check. I found no other open PR covering this CLI. Commands run (Linux): - `python3 -B tests/startup_audio_timeline_cli_check.py`: 5 tests OK - `python3 -B tests/startup_audio_timeline_check.py`: OK - `git diff --check origin/main...HEAD`: clean - `python3 tests/bidi_controls_check.py`: pass - Mutation 1: remove `csv.Error` from the except tuple. The new suite fails. - Mutation 2: disable both `is_dir()` guards. The new suite fails. - Both mutations reverted with `git checkout -- .`. Non-blocking note: on Linux and Windows, opening a directory already raises an `OSError` (`IsADirectoryError` / `PermissionError`), which the existing `except` turns into exit 2. So the `is_dir()` guards only change the message text. If you want less code, you could drop them and keep the test on the exit code. Fine to keep as is. No blocking findings. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 20:04:13 +00:00
tedin7 commented 2026-11-25 20:04:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:28:04Z.

Review: COMMENTED


Review of head d596e5ba (after update-branch with main). Comment only.

Checked:

  • tools/startup_audio_timeline.py: main(argv) forwards to parse_args, returns 0, raise SystemExit(main()); directory guards and csv.Error go through parser.error (exit 2). JSON stdout unchanged.
  • tests/startup_audio_timeline_cli_check.py guards the new behavior through the CLI (stdout, exit code), including missing/directory inputs, NUL/field-limit csv errors, bad JSONL, NaN/Inf.
  • CMake registration sits next to the existing startup_audio_timeline test. No other open or merged PR covers this slice (#1870 only added the CI hook).

Commands run (Linux, worktree at this head):

  • python3 tests/startup_audio_timeline_cli_check.py -> 5 tests OK
  • python3 tests/startup_audio_timeline_check.py -> 3 tests OK
  • python3 tests/docs_links_check.py and python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: drop csv.Error from the except tuple -> new suite fails.
  • Mutation 2: disable the inputs directory guard -> new suite fails.

No blocking findings. Pure Python tooling, no game or startup claim.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6063714320 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2440#pullrequestreview-6063714320). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:28:04Z. **Review:** COMMENTED --- Review of head d596e5ba (after update-branch with main). Comment only. Checked: - `tools/startup_audio_timeline.py`: `main(argv)` forwards to `parse_args`, returns 0, `raise SystemExit(main())`; directory guards and `csv.Error` go through `parser.error` (exit 2). JSON stdout unchanged. - `tests/startup_audio_timeline_cli_check.py` guards the new behavior through the CLI (stdout, exit code), including missing/directory inputs, NUL/field-limit csv errors, bad JSONL, NaN/Inf. - CMake registration sits next to the existing `startup_audio_timeline` test. No other open or merged PR covers this slice (#1870 only added the CI hook). Commands run (Linux, worktree at this head): - `python3 tests/startup_audio_timeline_cli_check.py` -> 5 tests OK - `python3 tests/startup_audio_timeline_check.py` -> 3 tests OK - `python3 tests/docs_links_check.py` and `python3 tests/bidi_controls_check.py` -> OK - `git diff --check origin/main...HEAD` -> clean - Mutation 1: drop `csv.Error` from the except tuple -> new suite fails. - Mutation 2: disable the `inputs` directory guard -> new suite fails. No blocking findings. Pure Python tooling, no game or startup claim. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 20:04:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:40:29Z.


Win2025 WARP receipt for head d596e5ba after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit d596e5baea9defdda35f403344a61d5cf13e9ffb:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 255.22s (configure 7.96s)
    • Test (ctest --preset dev -R 'startup_audio_timeline' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (7.31s: startup_audio_timeline 2.32s, startup_audio_timeline_cli_check 7.14s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 211.67s (configure 3.63s)
    • Test (ctest --preset release -R 'startup_audio_timeline' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (5.09s: startup_audio_timeline 1.83s, startup_audio_timeline_cli_check 4.93s)
  • Windows Python checks: tests/startup_audio_timeline_check.py ok (6.2s)
  • sccache: 53/-172 hits; wall 519.1s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7172617805 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2440#issuecomment-7172617805). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T19:40:29Z. --- Win2025 WARP receipt for head d596e5ba after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `d596e5baea9defdda35f403344a61d5cf13e9ffb`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `255.22s` (configure `7.96s`) - Test (`ctest --preset dev -R 'startup_audio_timeline' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`7.31s`: `startup_audio_timeline` `2.32s`, `startup_audio_timeline_cli_check` `7.14s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `211.67s` (configure `3.63s`) - Test (`ctest --preset release -R 'startup_audio_timeline' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`5.09s`: `startup_audio_timeline` `1.83s`, `startup_audio_timeline_cli_check` `4.93s`) - **Windows Python checks**: `tests/startup_audio_timeline_check.py` ok (`6.2s`) - `sccache`: 53/-172 hits; wall `519.1s` 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!2432
No description provided.