stage_timeline: a missing or unreadable log is one error line; add unit tests (TOOL-STAGE-TIMELINE-TESTS) #2232

Closed
github-bot wants to merge 2 commits from github-bot/gh-2232 into main AGit
Owner

@⁠real-rusher on GitHub · 2026-11-26 09:00 UTC · original
real-rusher:stage-timeline-tests → main · +171 −1 · 2 files · 2 commits · closed without merging

Claimed in the coordination issue as: TOOL-STAGE-TIMELINE-TESTS (#1608)

What and why

tools/stage_timeline.py had no tests, and a wrong path or a folder ended in a FileNotFoundError or IsADirectoryError traceback. It now prints stage_timeline: error: cannot read <log>: <reason> and exits 2, like awc_names and check_no_game_data.

tests/test_stage_timeline.py covers read() and timeline() on synthetic logs (stage changes, "?" and list values, the session low dword, unknown values, press pairing, the loading screen end) and the command line (text and JSON reports, no peek lines, a missing log, a folder). Standard library only, no game data.

Tested

python -I tests/test_stage_timeline.py: 13 tests pass. On main, the two error tests fail and the other 11 pass.
Also run: python -m compileall -q make_game.py tools tests, scripts/check_no_game_data.py on both files, tests/test_ci_registration.py, tests/test_text_write_line_endings.py. All pass. Linux, Python 3.13.

GPUs tested: n/a

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a, no translator change)

🤖 Assisted by Claude Code

**@⁠real-rusher** on GitHub · 2026-11-26 09:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2232) `real-rusher:stage-timeline-tests` → `main` · +171 −1 · 2 files · 2 commits · closed without merging Claimed in the coordination issue as: TOOL-STAGE-TIMELINE-TESTS (#1608) ### What and why tools/stage_timeline.py had no tests, and a wrong path or a folder ended in a FileNotFoundError or IsADirectoryError traceback. It now prints `stage_timeline: error: cannot read <log>: <reason>` and exits 2, like awc_names and check_no_game_data. tests/test_stage_timeline.py covers read() and timeline() on synthetic logs (stage changes, "?" and list values, the session low dword, unknown values, press pairing, the loading screen end) and the command line (text and JSON reports, no peek lines, a missing log, a folder). Standard library only, no game data. ### Tested python -I tests/test_stage_timeline.py: 13 tests pass. On main, the two error tests fail and the other 11 pass. Also run: python -m compileall -q make_game.py tools tests, scripts/check_no_game_data.py on both files, tests/test_ci_registration.py, tests/test_text_write_line_endings.py. All pass. Linux, Python 3.13. GPUs tested: n/a AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a, no translator change) 🤖 Assisted by [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:23:59 +00:00
Author
Owner

@⁠ecox982745 on GitHub · 2026-11-26 09:16 UTC · original

All 13 tests passed on Windows with Python 3.13.18 at afeee543b, including the directory and missing-file cases. I also checked the overlap with #2186 (132b131b8) and #1789 (dacbc1656) using synthetic logs. Those branches independently passed 5 and 7 tests, respectively.

There are two merge conflicts worth coordinating. #2186 changes the arguments to read() on the same line this PR wraps with try/except OSError. #1789 implements the same file-error behavior and introduces a different suite at the same path, tests/test_stage_timeline.py.

I tested a local resolution against main a73a57e13. Combining this PR's error handler with #2186's configured reader and running this PR's tests unadapted gave 2/13 passing. The fixtures call the old reader or CLI and expect the old no-peek diagnostic. The error tests also need configured addresses so they reach the file open.

All 25 tests passed together after retaining the separate parser cases from #1789 and making these fixture changes:

  • Pass the three synthetic field addresses to read() and to the CLI helper. Dummy hex values 1a, 2b, and 3c worked throughout.
  • In the empty-log case, check for LEONIDA_PEEK in the diagnostic. The configured reader no longer prints a literal LEONIDA_PEEK= command.
  • Keep both test modules under distinct names and use one file-error handler around the configured read() call. This preserves this PR's single-line diagnostic, #1789's malformed-input cases, and #2186's configurable-field behavior.

This was a local CPU integration check.

**@⁠ecox982745** on GitHub · 2026-11-26 09:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2232#issuecomment-7187708454) All 13 tests passed on Windows with Python 3.13.18 at `afeee543b`, including the directory and missing-file cases. I also checked the overlap with #2186 (`132b131b8`) and #1789 (`dacbc1656`) using synthetic logs. Those branches independently passed 5 and 7 tests, respectively. There are two merge conflicts worth coordinating. #2186 changes the arguments to `read()` on the same line this PR wraps with `try/except OSError`. #1789 implements the same file-error behavior and introduces a different suite at the same path, `tests/test_stage_timeline.py`. I tested a local resolution against main `a73a57e13`. Combining this PR's error handler with #2186's configured reader and running this PR's tests unadapted gave **2/13 passing**. The fixtures call the old reader or CLI and expect the old no-peek diagnostic. The error tests also need configured addresses so they reach the file open. **All 25 tests passed together** after retaining the separate parser cases from #1789 and making these fixture changes: - Pass the three synthetic field addresses to `read()` and to the CLI helper. Dummy hex values `1a`, `2b`, and `3c` worked throughout. - In the empty-log case, check for `LEONIDA_PEEK` in the diagnostic. The configured reader no longer prints a literal `LEONIDA_PEEK=` command. - Keep both test modules under distinct names and use one file-error handler around the configured `read()` call. This preserves this PR's single-line diagnostic, #1789's malformed-input cases, and #2186's configurable-field behavior. This was a local CPU integration check.
Author
Owner

@⁠GrahamboJangles on GitHub · 2026-11-26 09:18 UTC · original

Review pass on Windows (this box has no cmake/clang-cl, so no C++ build was run; this PR is pure Python tooling, so that is all the verification needed here).

Head afeee543b fetched into the local clone as branch pr2232; diff against base a73a57e13 is exactly one hunk in tools/stage_timeline.py — the peeks, presses = read(a.log) line moves into a try/except OSError that prints one stderr line (stage_timeline: error: cannot read <log>: <reason>) and return 2 — plus the new tests/test_stage_timeline.py (166 lines, 13 tests). No other files touched.

What I ran on this machine (Windows 11, CPython 3.14.9, all via python -I):

  • At head: python -I tests/test_stage_timeline.py -v → Ran 13 tests, OK.
  • Same test file against the tool at base main a73a57e13 (the test file copied into a scratch tree so it locates the base tool via its own relative path): Ran 13 tests, FAILED (failures=2) — the two error-line tests (missing log, folder). Pass count moved 11 → 13, so the new tests genuinely exercise the change rather than replacing old ones.
  • python -m compileall -q make_game.py tools tests exit 0; scripts/check_no_game_data.py on both files exit 0; python -I tests/test_ci_registration.py OK (16 tests), all at head.

From reading the hunk: IsADirectoryError and PermissionError are OSError subclasses, so folders and unreadable paths take the one-line path; undecodable bytes were already absorbed by errors="replace" in read(). Exit code 2 flows from sys.exit(main()) with return 2, matching the awc_names / check_no_game_data convention as described.

The author's numbers (Linux, 3.13) reproduce identically on Windows/3.14. Nothing blocking.

**@⁠GrahamboJangles** on GitHub · 2026-11-26 09:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2232#issuecomment-7187771162) Review pass on Windows (this box has no cmake/clang-cl, so no C++ build was run; this PR is pure Python tooling, so that is all the verification needed here). Head `afeee543b` fetched into the local clone as branch `pr2232`; diff against base `a73a57e13` is exactly one hunk in `tools/stage_timeline.py` — the `peeks, presses = read(a.log)` line moves into a `try/except OSError` that prints one stderr line (`stage_timeline: error: cannot read <log>: <reason>`) and `return 2` — plus the new `tests/test_stage_timeline.py` (166 lines, 13 tests). No other files touched. What I ran on this machine (Windows 11, CPython 3.14.9, all via `python -I`): - At head: `python -I tests/test_stage_timeline.py -v` → Ran 13 tests, OK. - Same test file against the tool at base `main` `a73a57e13` (the test file copied into a scratch tree so it locates the base tool via its own relative path): Ran 13 tests, FAILED (failures=2) — the two error-line tests (missing log, folder). Pass count moved 11 → 13, so the new tests genuinely exercise the change rather than replacing old ones. - `python -m compileall -q make_game.py tools tests` exit 0; `scripts/check_no_game_data.py` on both files exit 0; `python -I tests/test_ci_registration.py` OK (16 tests), all at head. From reading the hunk: `IsADirectoryError` and `PermissionError` are `OSError` subclasses, so folders and unreadable paths take the one-line path; undecodable bytes were already absorbed by `errors="replace"` in `read()`. Exit code 2 flows from `sys.exit(main())` with `return 2`, matching the `awc_names` / `check_no_game_data` convention as described. The author's numbers (Linux, 3.13) reproduce identically on Windows/3.14. Nothing blocking.
Author
Owner

@⁠DeadlyChirp on GitHub · 2026-11-26 10:02 UTC · original · edited 2026-11-26 10:30 UTC

Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

  • tests/test_stage_timeline.py: 13 passed.
  • The new tests against main code: 2 failed (the open(path, ...) call in assert_one_error_line), so they catch the bug this PR fixes.

(AI-assisted test run; output checked by hand.)

**@⁠DeadlyChirp** on GitHub · 2026-11-26 10:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2232#issuecomment-7188817057) · edited 2026-11-26 10:30 UTC Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. - `tests/test_stage_timeline.py`: 13 passed. - The new tests against main code: 2 failed (the `open(path, ...)` call in `assert_one_error_line`), so they catch the bug this PR fixes. (AI-assisted test run; output checked by hand.)
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 10:12 UTC · original

Conflicts with: #2186 (tools: read boot timeline states from the configured RVAs). Both change main() in tools/stage_timeline.py, and #2186 makes read() and the CLI take the state RVAs, which this PR's tests do not pass yet. If #2186 lands first, I will rebase this PR onto it and update tests/test_stage_timeline.py to the RVA arguments; if this one lands first, #2186 only needs to keep the OSError guard around its read() call.

**@⁠real-rusher** on GitHub · 2026-11-26 10:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2232#issuecomment-7189064059) Conflicts with: #2186 (tools: read boot timeline states from the configured RVAs). Both change main() in tools/stage_timeline.py, and #2186 makes read() and the CLI take the state RVAs, which this PR's tests do not pass yet. If #2186 lands first, I will rebase this PR onto it and update tests/test_stage_timeline.py to the RVA arguments; if this one lands first, #2186 only needs to keep the OSError guard around its read() call.
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 11:12 UTC · original · reviewed

Windows 11: 13/13 stage timeline tests passed, including the CLI's missing/unreadable-input diagnostics. No findings.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 11:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2232#pullrequestreview-6073135610) · **reviewed** Windows 11: 13/13 stage timeline tests passed, including the CLI's missing/unreadable-input diagnostics. No findings. AI-assisted.
github-bot closed this pull request 2026-11-26 13:44:37 +00:00
Author
Owner

@⁠real-rusher on GitHub · 2026-11-26 13:41 UTC · original

Closing as a duplicate of #1789 (STAGE-TIMELINE-STDOUT-GUARD-AND-PARSER-SAFETY), which is older, makes the same OSError change and adds tests/test_stage_timeline.py at the same path. I missed it when I claimed this. Thanks to everyone who verified this one, and to @⁠ecox982745 for pointing out the overlap. If the timeline and CLI cases here are wanted on top of #1789, they can follow as a separate test file once #1789 and #2186 have landed.

**@⁠real-rusher** on GitHub · 2026-11-26 13:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2232#issuecomment-7193713639) Closing as a duplicate of #1789 (STAGE-TIMELINE-STDOUT-GUARD-AND-PARSER-SAFETY), which is older, makes the same OSError change and adds tests/test_stage_timeline.py at the same path. I missed it when I claimed this. Thanks to everyone who verified this one, and to @⁠ecox982745 for pointing out the overlap. If the timeline and CLI cases here are wanted on top of #1789, they can follow as a separate test file once #1789 and #2186 have landed.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.