progress_dashboard: recover parse_lasttest after incomplete nested CTest logs (DASH-CTEST-INCOMPLETE-NESTED) #1256

Merged
IlyassRS3 merged 3 commits from upstream-pr/1256 into main 2026-11-28 22:21:54 +00:00
IlyassRS3 commented 2026-11-24 20:57:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-24T20:57:27Z.


What changed

Fixes parse_lasttest in tools/progress_dashboard.py so an incomplete nested CTest log inside a test's captured Output: block (such as a nested run missing its trailing End testing: line, or truncated mid-output) no longer swallows the outer test's verdict and all subsequent outer test results.

Addresses the findings in #14 (finding #7143409370 and the real CTest 3.31.10 fixture in finding #7144069427).

Why this works even when inner and outer share name, ordinal, and timestamps

In CTest LastTest.log, every test output inside a nested run is bracketed by Output: + 58 dashes and <end of output> + Test time =. Instead of a flat nested_runs counter that can only close on End testing:, parse_lasttest now tracks a stack of [in_output, inner_test_name] frames for each nested Start testing: + 58-dash block:

  • An inner Output: + 58 dashes sets in_output = True for the innermost nested run, and the inner test's <end of output> flips it back to False while staying inside outer capture (so inner wrapper pass verdicts are still ignored even when name, ordinal, and timestamps match the outer test).
  • When <end of output> + Test time = arrives with in_output == False on the top nested frame(s), no inner Output: block is open, so those completed-but-unclosed nested runs (missing End testing:) are popped cleanly; if the stack empties, outer capture ends immediately, and in 3-level nesting an enclosing middle test's Output: closes while staying inside outer capture.
  • When an inner test (with a different name than the outer test) was truncated mid-Output: before its own <end of output>, _trailer_end_time_matches checks the immediate "<name>" end time: trailer (stopping at the first end-time line or second 58-dash separator) to resynchronize on the outer test.
  • Spurious End testing: lines printed inside a nested test's captured Output: are ignored while in_output is True, preventing premature exit from outer capture.

Tests added (tests/test_progress_dashboard.py)

  1. test_lasttest_recovers_when_nested_log_omits_end_testing (reproduces the real CTest 3.31.10 fixture: outer wrapper 1/2 fails, inner wrapper 1/2 passes + child_2 2/2 passes with identical timestamps and missing End testing:, followed by outer later 2/2 passing).
  2. test_lasttest_recovers_from_empty_incomplete_nested_log (reproduces finding #7143409370).
  3. test_lasttest_handles_three_level_nested_log_missing_innermost_end_testing.
  4. test_lasttest_recovers_when_inner_test_output_is_truncated_mid_stream.
  5. test_lasttest_ignores_spurious_end_testing_inside_nested_test_output.

Item ID

  • Coordination issue #14 item: DASH-CTEST-INCOMPLETE-NESTED
  • Depends on: none (zero hunk overlap with open PRs #625, #965, #1001)

Verification

Tested on macOS 27.2.1 (Apple M5 arm64), Python 3.14 (no game files, no GPU, standard library only):

  • python3 -I tests/test_progress_dashboard.py -v -> 56/56 OK
  • Revert-source mutation check (reverting tools/progress_dashboard.py to upstream/main while keeping tests/test_progress_dashboard.py) -> FAILED (5 failures): all 5 new tests fail on main (4 return [], 1 falsely reports ('wrapper', 'pass', 0.01) instead of ('wrapper', 'fail', 0.15)); restoring the fix returns to 56/56 OK.
  • python3 -m compileall -q tools/progress_dashboard.py tests/test_progress_dashboard.py -> OK
  • python3 -I scripts/check_no_game_data.py tools/progress_dashboard.py tests/test_progress_dashboard.py -> OK
  • python3 -I tests/test_ci_registration.py -> 15/15 OK
  • python3 -I tests/test_text_write_line_endings.py -> 3/3 OK

Checklist

  • No game files, binaries, shaders, textures, audio, or logs quoting them
  • No keys, decryption, or online services
  • Claimed in the coordination issue (#14) before opening this PR
  • AI-assisted: yes (designed, implemented, and regression-verified with AI assistance)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5480204649 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1256). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-24T20:57:27Z. --- ## What changed Fixes `parse_lasttest` in `tools/progress_dashboard.py` so an incomplete nested CTest log inside a test's captured `Output:` block (such as a nested run missing its trailing `End testing:` line, or truncated mid-output) no longer swallows the outer test's verdict and all subsequent outer test results. Addresses the findings in #14 ([finding #7143409370](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143409370) and the real CTest 3.31.10 fixture in [finding #7144069427](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144069427)). ### Why this works even when inner and outer share name, ordinal, and timestamps In CTest `LastTest.log`, every test output inside a nested run is bracketed by `Output:` + 58 dashes and `<end of output>` + `Test time =`. Instead of a flat `nested_runs` counter that can only close on `End testing:`, `parse_lasttest` now tracks a stack of `[in_output, inner_test_name]` frames for each nested `Start testing:` + 58-dash block: - An inner `Output:` + 58 dashes sets `in_output = True` for the innermost nested run, and the inner test's `<end of output>` flips it back to `False` while staying inside outer capture (so inner `wrapper` pass verdicts are still ignored even when name, ordinal, and timestamps match the outer test). - When `<end of output>` + `Test time =` arrives with `in_output == False` on the top nested frame(s), no inner `Output:` block is open, so those completed-but-unclosed nested runs (missing `End testing:`) are popped cleanly; if the stack empties, outer capture ends immediately, and in 3-level nesting an enclosing middle test's `Output:` closes while staying inside outer capture. - When an inner test (with a different name than the outer test) was truncated mid-`Output:` before its own `<end of output>`, `_trailer_end_time_matches` checks the immediate `"<name>" end time: ` trailer (stopping at the first end-time line or second 58-dash separator) to resynchronize on the outer test. - Spurious `End testing:` lines printed inside a nested test's captured `Output:` are ignored while `in_output` is `True`, preventing premature exit from outer capture. ### Tests added (`tests/test_progress_dashboard.py`) 1. `test_lasttest_recovers_when_nested_log_omits_end_testing` (reproduces the real CTest 3.31.10 fixture: outer `wrapper` 1/2 fails, inner `wrapper` 1/2 passes + `child_2` 2/2 passes with identical timestamps and missing `End testing:`, followed by outer `later` 2/2 passing). 2. `test_lasttest_recovers_from_empty_incomplete_nested_log` (reproduces finding #7143409370). 3. `test_lasttest_handles_three_level_nested_log_missing_innermost_end_testing`. 4. `test_lasttest_recovers_when_inner_test_output_is_truncated_mid_stream`. 5. `test_lasttest_ignores_spurious_end_testing_inside_nested_test_output`. ## Item ID - Coordination issue #14 item: `DASH-CTEST-INCOMPLETE-NESTED` - Depends on: none (zero hunk overlap with open PRs #625, #965, #1001) ## Verification Tested on macOS 27.2.1 (Apple M5 arm64), Python 3.14 (no game files, no GPU, standard library only): - `python3 -I tests/test_progress_dashboard.py -v` -> **56/56 OK** - Revert-source mutation check (reverting `tools/progress_dashboard.py` to `upstream/main` while keeping `tests/test_progress_dashboard.py`) -> **FAILED (5 failures)**: all 5 new tests fail on `main` (4 return `[]`, 1 falsely reports `('wrapper', 'pass', 0.01)` instead of `('wrapper', 'fail', 0.15)`); restoring the fix returns to 56/56 OK. - `python3 -m compileall -q tools/progress_dashboard.py tests/test_progress_dashboard.py` -> OK - `python3 -I scripts/check_no_game_data.py tools/progress_dashboard.py tests/test_progress_dashboard.py` -> OK - `python3 -I tests/test_ci_registration.py` -> **15/15 OK** - `python3 -I tests/test_text_write_line_endings.py` -> **3/3 OK** ## Checklist - [x] No game files, binaries, shaders, textures, audio, or logs quoting them - [x] No keys, decryption, or online services - [x] Claimed in the coordination issue (#14) before opening this PR - [x] AI-assisted: yes (designed, implemented, and regression-verified with AI assistance)
copilot-pull-request-reviewer[bot] commented 2026-11-24 20:57:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T20:57:35Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6047281518 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1256#pullrequestreview-6047281518). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-24T20:57:35Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
titoreinaldo commented 2026-11-24 21:23:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by titoreinaldo on 2026-11-24T21:23:44Z.


I reran the real CTest 3.31.10 fixture against this PR on Linux: base lost both results with the truncated log; f4824083 recovered wrapper=fail and later=pass, with the same results as the intact log. The 13 parser/registration tests in the Tests class passed. One small performance follow-up: _trailer_end_time_matches copies the entire remaining suffix with lines[end_of_output_index + 1:] on every normal inner trailer whose name differs from the outer test. A synthetic nested run with 4,000 tests took 187 ms, and 8,000 took 711 ms (three-run medians). Iterating by index without copying the suffix reduced those to 18 and 38 ms, with identical outer results. Could we use indexed iteration so the early stop also bounds the work? CPU-only; AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144872916 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7144872916). Originally posted by [titoreinaldo](https://github.com/titoreinaldo) on 2026-11-24T21:23:44Z. --- I reran the real CTest 3.31.10 fixture against this PR on Linux: base lost both results with the truncated log; `f4824083` recovered `wrapper=fail` and `later=pass`, with the same results as the intact log. The 13 parser/registration tests in the `Tests` class passed. One small performance follow-up: `_trailer_end_time_matches` copies the entire remaining suffix with `lines[end_of_output_index + 1:]` on every normal inner trailer whose name differs from the outer test. A synthetic nested run with 4,000 tests took 187 ms, and 8,000 took 711 ms (three-run medians). Iterating by index without copying the suffix reduced those to 18 and 38 ms, with identical outer results. Could we use indexed iteration so the early stop also bounds the work? CPU-only; AI-assisted.
IlyassRS3 commented 2026-11-24 21:27:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-24T21:27:03Z.


Thanks for testing against the real CTest 3.31.10 fixture and spotting the quadratic slice, @titoreinaldo!

Pushed 8d2aa7bd8 switching _trailer_end_time_matches to indexed iteration (range(end_of_output_index + 1, len(lines))) and reusing module-level _CTEST_HEADER_RE. Verified python3 -I tests/test_progress_dashboard.py (56/56 OK) and linear scaling on a synthetic nested log (4,000 tests: 6.3 ms median; 8,000 tests: 12.6 ms median on Apple M5 / Python 3.14; CPU-only, AI-assisted).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144945488 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7144945488). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-24T21:27:03Z. --- Thanks for testing against the real CTest 3.31.10 fixture and spotting the quadratic slice, @titoreinaldo! Pushed `8d2aa7bd8` switching `_trailer_end_time_matches` to indexed iteration (`range(end_of_output_index + 1, len(lines))`) and reusing module-level `_CTEST_HEADER_RE`. Verified `python3 -I tests/test_progress_dashboard.py` (56/56 OK) and linear scaling on a synthetic nested log (4,000 tests: 6.3 ms median; 8,000 tests: 12.6 ms median on Apple M5 / Python 3.14; CPU-only, AI-assisted).
DeadlyChirp commented 2026-11-24 21:40:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-24T21:40:39Z.


I reproduced a case where the dashboard drops the following test as well as the failed wrapper. On 8d2aa7bd, Windows 11, Python 3.12.10, CTest 4.4.4, I generated three LastTest.log files using real CTest runs:

  1. Run a test named leaf that prints a unique line, e.g. leaf payload.
  2. Run a test named middle that prints the entire leaf LastTest.log.
  3. In an outer suite, have wrapper print the middle LastTest.log only through the first occurrence of the leaf payload line, then exit 1. A second test later exits 0. Run this suite with ctest --output-junit results.xml.
  4. Call parse_lasttest on the outer LastTest.log. The result was []; JUnit recorded wrapper=fail, later=pass. As a control, printing the complete middle log in step 3 yielded both correct dashboard results.

At the real wrapper trailer both nested Output blocks are still open, so the recovery guarded by len(nested) == 1 never tests the matching wrapper end time. This differs from omitting just the innermost End testing line: its test trailer is also missing. A regression case should check that the later result survives as well.

CPU-only, synthetic output, AI-assisted review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145244457 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7145244457). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-24T21:40:39Z. --- I reproduced a case where the dashboard drops the *following* test as well as the failed wrapper. On 8d2aa7bd, Windows 11, Python 3.12.10, CTest 4.4.4, I generated three LastTest.log files using real CTest runs: 1. Run a test named `leaf` that prints a unique line, e.g. `leaf payload`. 2. Run a test named `middle` that prints the entire leaf LastTest.log. 3. In an outer suite, have `wrapper` print the middle LastTest.log **only through the first occurrence of the leaf payload line**, then exit 1. A second test `later` exits 0. Run this suite with `ctest --output-junit results.xml`. 4. Call `parse_lasttest` on the outer LastTest.log. The result was `[]`; JUnit recorded `wrapper=fail, later=pass`. As a control, printing the complete middle log in step 3 yielded both correct dashboard results. At the real wrapper trailer both nested Output blocks are still open, so the recovery guarded by `len(nested) == 1` never tests the matching wrapper end time. This differs from omitting just the innermost End testing line: its test trailer is also missing. A regression case should check that the later result survives as well. CPU-only, synthetic output, AI-assisted review.
IlyassRS3 commented 2026-11-24 21:46:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-24T21:46:24Z.


Great catch, @DeadlyChirp — reproduced your exact 3-level wrapper -> middle -> leaf mid-leaf truncation case on 8d2aa7bd8 ([] instead of [('wrapper', 'fail', ...), ('later', 'pass', ...)]).

Pushed c81b2daf5 generalizing trailer recovery to arbitrary nesting depths:

  • Replaced _trailer_end_time_matches with _trailer_end_time_name (still indexed O(1) per trailer).
  • On <end of output> + Test time =, unwinds any already-closed frames, matches the immediate trailer's "<name>" end time: against the innermost matching open frame in nested (unwinding truncated deeper frames), and when no open nested frame matches and trailer_name == name, unwinds all open nested frames to close the outer test.
  • Added test_lasttest_recovers_when_multi_level_nested_output_is_truncated_mid_leaf and test_lasttest_recovers_when_middle_finishes_after_truncated_leaf (both verifying wrapper and later survive).

Verified python3 -I tests/test_progress_dashboard.py (58/58 OK) and linear scaling on a synthetic nested log (4,000 tests: 6.6 ms; 8,000 tests: 13.5 ms on Apple M5 / Python 3.14; CPU-only, AI-assisted).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145367913 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7145367913). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-24T21:46:24Z. --- Great catch, @DeadlyChirp — reproduced your exact 3-level `wrapper -> middle -> leaf` mid-leaf truncation case on `8d2aa7bd8` (`[]` instead of `[('wrapper', 'fail', ...), ('later', 'pass', ...)]`). Pushed `c81b2daf5` generalizing trailer recovery to arbitrary nesting depths: - Replaced `_trailer_end_time_matches` with `_trailer_end_time_name` (still indexed O(1) per trailer). - On `<end of output>` + `Test time =`, unwinds any already-closed frames, matches the immediate trailer's `"<name>" end time:` against the innermost matching open frame in `nested` (unwinding truncated deeper frames), and when no open nested frame matches and `trailer_name == name`, unwinds all open nested frames to close the outer test. - Added `test_lasttest_recovers_when_multi_level_nested_output_is_truncated_mid_leaf` and `test_lasttest_recovers_when_middle_finishes_after_truncated_leaf` (both verifying `wrapper` and `later` survive). Verified `python3 -I tests/test_progress_dashboard.py` (58/58 OK) and linear scaling on a synthetic nested log (4,000 tests: 6.6 ms; 8,000 tests: 13.5 ms on Apple M5 / Python 3.14; CPU-only, AI-assisted).
TheGeogeo commented 2026-11-28 22:10:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T22:10:23Z.


Tested c81b2daf5 merged (no commit) with main aa918e5d9, Python 3.12.4, Windows 11, CPU only.

  • Green: python -I tests/test_progress_dashboard.py: 60 tests, 1 failure, test_default_repo_is_the_one_the_readme_clones. It fails the same way on plain main (the README no longer clones ubiquitarianism/leonida), so it is unrelated.
  • Red: with tools/progress_dashboard.py back to main, the 7 new test_lasttest_* tests fail (nested logs missing End testing:, truncated mid-stream, spurious End testing: in nested output).
  • Merges cleanly together with #1274 and #625. With all three, 66 tests run, with only the same main failure.
  • check_no_game_data.py is clean.

No blocker from my side. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246547085 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1256#issuecomment-7246547085). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T22:10:23Z. --- Tested `c81b2daf5` merged (no commit) with `main` `aa918e5d9`, Python 3.12.4, Windows 11, CPU only. - Green: `python -I tests/test_progress_dashboard.py`: 60 tests, 1 failure, `test_default_repo_is_the_one_the_readme_clones`. It fails the same way on plain `main` (the README no longer clones `ubiquitarianism/leonida`), so it is unrelated. - Red: with `tools/progress_dashboard.py` back to `main`, the 7 new `test_lasttest_*` tests fail (nested logs missing `End testing:`, truncated mid-stream, spurious `End testing:` in nested output). - Merges cleanly together with #1274 and #625. With all three, 66 tests run, with only the same `main` failure. - `check_no_game_data.py` is clean. No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-28 22:21:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T22:21:56Z.


Merged after TheGeogeo's red/green check (https://github.com/ProjectLeonida/mandy/pull/1256#issuecomment-7246547085) and a local re-check here: merged onto main c7753ed98 without conflict, tests/test_progress_dashboard.py shows the same single failure with and without this PR (test_default_repo_is_the_one_the_readme_clones, already red on main: the README no longer clones ubiquitarianism/leonida), and every other test passes. CI no-game-data check is green.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246684225 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1256#issuecomment-7246684225). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T22:21:56Z. --- Merged after **TheGeogeo**'s red/green check (https://github.com/ProjectLeonida/mandy/pull/1256#issuecomment-7246547085) and a local re-check here: merged onto `main` c7753ed98 without conflict, `tests/test_progress_dashboard.py` shows the same single failure with and without this PR (`test_default_repo_is_the_one_the_readme_clones`, already red on `main`: the README no longer clones ubiquitarianism/leonida), and every other test passes. CI no-game-data check is green. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
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
ProjectLeonida/mandy!1256
No description provided.