diff options
| author | IlyassRS <ilyassroussi2000@gmail.com> | 2026-11-24 22:46:21 +0100 |
|---|---|---|
| committer | IlyassRS <ilyassroussi2000@gmail.com> | 2026-11-24 22:46:21 +0100 |
| commit | c81b2daf57644e350f7d1084eceee1a64cc4db29 (patch) | |
| tree | 3b38bb1441d33352c110d25baf57c1a512c510a9 /tools/progress_dashboard.py | |
| parent | 8d2aa7bd803d0f8547f36697cc9c71b9a247075d (diff) | |
progress_dashboard: unwind multi-level truncated nested CTest outputs by trailer name
Diffstat (limited to 'tools/progress_dashboard.py')
| -rw-r--r-- | tools/progress_dashboard.py | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/tools/progress_dashboard.py b/tools/progress_dashboard.py index 0e5d95907..2f3219eb3 100644 --- a/tools/progress_dashboard.py +++ b/tools/progress_dashboard.py | |||
| @@ -403,25 +403,26 @@ def parse_junit(xml): | |||
| 403 | _CTEST_HEADER_RE = re.compile(r"^\d+/\d+ Test: (.+)$") | 403 | _CTEST_HEADER_RE = re.compile(r"^\d+/\d+ Test: (.+)$") |
| 404 | 404 | ||
| 405 | 405 | ||
| 406 | def _trailer_end_time_matches(lines: list[str], end_of_output_index: int, name: str) -> bool: | 406 | def _trailer_end_time_name(lines: list[str], end_of_output_index: int) -> str | None: |
| 407 | """True when the immediate CTest trailer after `<end of output>` ends with `\"<name>\" end time: `.""" | 407 | """Return `<name>` from the immediate CTest trailer's `\"<name>\" end time: ` line, or None.""" |
| 408 | sep = "-" * 58 | 408 | sep = "-" * 58 |
| 409 | separators = 0 | 409 | separators = 0 |
| 410 | expected = f'"{name}" end time: ' | ||
| 411 | for idx in range(end_of_output_index + 1, len(lines)): | 410 | for idx in range(end_of_output_index + 1, len(lines)): |
| 412 | line = lines[idx] | 411 | line = lines[idx] |
| 413 | if line == sep: | 412 | if line == sep: |
| 414 | separators += 1 | 413 | separators += 1 |
| 415 | if separators >= 2: | 414 | if separators >= 2: |
| 416 | return False | 415 | return None |
| 417 | continue | 416 | continue |
| 418 | if line.startswith('"') and '" end time: ' in line: | 417 | if line.startswith('"'): |
| 419 | return line.startswith(expected) | 418 | marker = line.rfind('" end time: ') |
| 419 | if marker > 0: | ||
| 420 | return line[1:marker] | ||
| 420 | if line == "<end of output>" or line == "Output:" or line.startswith(("Start testing: ", "End testing: ")): | 421 | if line == "<end of output>" or line == "Output:" or line.startswith(("Start testing: ", "End testing: ")): |
| 421 | return False | 422 | return None |
| 422 | if _CTEST_HEADER_RE.match(line): | 423 | if _CTEST_HEADER_RE.match(line): |
| 423 | return False | 424 | return None |
| 424 | return False | 425 | return None |
| 425 | 426 | ||
| 426 | 427 | ||
| 427 | def parse_lasttest(text: str) -> list[tuple[str, str, float | None]]: | 428 | def parse_lasttest(text: str) -> list[tuple[str, str, float | None]]: |
| @@ -438,6 +439,29 @@ def parse_lasttest(text: str) -> list[tuple[str, str, float | None]]: | |||
| 438 | # CTest writes child output verbatim, so it can contain complete or truncated nested logs. | 439 | # CTest writes child output verbatim, so it can contain complete or truncated nested logs. |
| 439 | if line.startswith("Start testing: ") and next_line == sep: | 440 | if line.startswith("Start testing: ") and next_line == sep: |
| 440 | nested.append([False, None]) | 441 | nested.append([False, None]) |
| 442 | elif line == "<end of output>" and next_line.startswith("Test time ="): | ||
| 443 | # Unwind any nested runs whose Output: block is already closed (or never opened) and omitted End testing:. | ||
| 444 | while nested and not nested[-1][0]: | ||
| 445 | nested.pop() | ||
| 446 | if not nested: | ||
| 447 | captured = False | ||
| 448 | else: | ||
| 449 | trailer_name = _trailer_end_time_name(lines, index) | ||
| 450 | matched_depth = None | ||
| 451 | if trailer_name is not None: | ||
| 452 | for depth in range(len(nested) - 1, -1, -1): | ||
| 453 | if nested[depth][1] == trailer_name: | ||
| 454 | matched_depth = depth | ||
| 455 | break | ||
| 456 | if matched_depth is not None: | ||
| 457 | del nested[matched_depth + 1:] | ||
| 458 | nested[matched_depth][0] = False | ||
| 459 | elif trailer_name is not None and trailer_name == name: | ||
| 460 | # All open nested Output: blocks were truncated before their own `<end of output>`. | ||
| 461 | nested.clear() | ||
| 462 | captured = False | ||
| 463 | else: | ||
| 464 | nested[-1][0] = False | ||
| 441 | elif nested and not nested[-1][0]: | 465 | elif nested and not nested[-1][0]: |
| 442 | m = _CTEST_HEADER_RE.match(line) | 466 | m = _CTEST_HEADER_RE.match(line) |
| 443 | if m: | 467 | if m: |
| @@ -446,24 +470,6 @@ def parse_lasttest(text: str) -> list[tuple[str, str, float | None]]: | |||
| 446 | nested[-1][0] = True | 470 | nested[-1][0] = True |
| 447 | elif line.startswith("End testing: "): | 471 | elif line.startswith("End testing: "): |
| 448 | nested.pop() | 472 | nested.pop() |
| 449 | elif line == "<end of output>" and next_line.startswith("Test time ="): | ||
| 450 | # No inner Output: block is open, so unwind any nested runs that omitted `End testing:`. | ||
| 451 | while nested and not nested[-1][0]: | ||
| 452 | nested.pop() | ||
| 453 | if not nested: | ||
| 454 | captured = False | ||
| 455 | else: | ||
| 456 | nested[-1][0] = False | ||
| 457 | elif line == "<end of output>" and next_line.startswith("Test time ="): | ||
| 458 | if not nested: | ||
| 459 | captured = False | ||
| 460 | elif (len(nested) == 1 and nested[0][1] is not None and nested[0][1] != name | ||
| 461 | and _trailer_end_time_matches(lines, index, name)): | ||
| 462 | # Inner test output was truncated before its own `<end of output>`; this trailer is the outer test's. | ||
| 463 | nested.clear() | ||
| 464 | captured = False | ||
| 465 | else: | ||
| 466 | nested[-1][0] = False | ||
| 467 | continue | 473 | continue |
| 468 | m = _CTEST_HEADER_RE.match(line) | 474 | m = _CTEST_HEADER_RE.match(line) |
| 469 | if m: | 475 | if m: |