Skip to content

Commit 1295e87

Browse files
[CI] Parse preceeding lines in mismatched failure messages (#170703)
In some cases ninja will emit FAILED: lines that are not immediately after a progress indicator. In these cases we also want to capture the preceeding context up to the last progress indicator as it is also part of the error message in the cases that we have seen. This fixes the rest of #165131.
1 parent 3c2e5d5 commit 1295e87

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.ci/generate_test_report_lib.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
6262
# aligned with the failure.
6363
failing_action = ninja_log[index].split("FAILED: ")[1]
6464
failure_log = []
65+
66+
# Parse the lines above the FAILED: string if the line does not come
67+
# immediately after a progress indicator to ensure that we capture the
68+
# entire failure message.
69+
if not ninja_log[index - 1].startswith("["):
70+
before_index = index - 1
71+
while before_index > 0 and not ninja_log[before_index].startswith("["):
72+
failure_log.append(ninja_log[before_index])
73+
before_index = before_index - 1
74+
failure_log.reverse()
75+
76+
# Parse the failure information, which comes after the FAILED: tag.
6577
while (
6678
index < len(ninja_log)
6779
and not ninja_log[index].startswith("[")

.ci/generate_test_report_lib_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def test_ninja_log_mismatched_failed(self):
181181
"tools/check-langley",
182182
dedent(
183183
"""\
184+
ModuleNotFoundError: No module named 'mount_langley'
184185
FAILED: tools/check-langley
185186
Wow! This system is really broken!"""
186187
),

0 commit comments

Comments
 (0)