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

Open
github-bot wants to merge 3 commits from github-bot/gh-1256 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-24 20:57 UTC · original
IlyassRS3:fix/dash-ctest-incomplete-nested → main · +190 −9 · 2 files · 3 commits · open

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)
**@⁠IlyassRS3** on GitHub · 2026-11-24 20:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1256) `IlyassRS3:fix/dash-ctest-incomplete-nested` → `main` · +190 −9 · 2 files · 3 commits · open ## 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://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) and the real CTest 3.31.10 fixture in [finding #7144069427](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:44:45 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-24 20:57 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-24 20:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1256#pullrequestreview-6047281518) · **reviewed** 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.
Author
Owner

@⁠titoreinaldo on GitHub · 2026-11-24 21:23 UTC · original

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.

**@⁠titoreinaldo** on GitHub · 2026-11-24 21:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7144872916) 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.
Author
Owner

@⁠IlyassRS3 on GitHub · 2026-11-24 21:27 UTC · original

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).

**@⁠IlyassRS3** on GitHub · 2026-11-24 21:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7144945488) 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).
Author
Owner

@⁠DeadlyChirp on GitHub · 2026-11-24 21:40 UTC · original

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.

**@⁠DeadlyChirp** on GitHub · 2026-11-24 21:40 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7145244457) 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.
Author
Owner

@⁠IlyassRS3 on GitHub · 2026-11-24 21:46 UTC · original

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).

**@⁠IlyassRS3** on GitHub · 2026-11-24 21:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1256#issuecomment-7145367913) 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).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1256/head:github-bot/gh-1256'
git switch 'github-bot/gh-1256'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1256'
git switch 'github-bot/gh-1256'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1256'
git switch 'github-bot/gh-1256'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1256'
git switch 'main'
git merge --squash 'github-bot/gh-1256'
git switch 'main'
git merge --ff-only 'github-bot/gh-1256'
git switch 'main'
git merge 'github-bot/gh-1256'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.