Skip to content

Commit 5256db3

Browse files
[CI] Use action from FAILED: in ninja log parser
There are cases where the progress indicator does not align at all with the action printed in FAILED:. Default to just using the action there so that we can ensure the results are accurate. This still leaves some issues where we are not capturing all the log lines, but I'll look at those in a future crash. Those are also less critical since they do not cause the script to patch. Partially fixes llvm#165131. Reviewers: DavidSpickett Reviewed By: DavidSpickett Pull Request: llvm#166100
1 parent 8395343 commit 5256db3

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

.ci/generate_test_report_lib.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
4141
# touch test/4.stamp
4242
#
4343
# index will point to the line that starts with Failed:. The progress
44-
# indicator is the line before this ([4/5] test/4.stamp) and contains a pretty
45-
# printed version of the target being built (test/4.stamp). We use this line
46-
# and remove the progress information to get a succinct name for the target.
47-
failing_action = ninja_log[index - 1].split("] ")[1]
44+
# indicator is sometimes the line before this ([4/5] test/4.stamp) and
45+
# will contain a pretty printed version of the target being built
46+
# (test/4.stamp) when accurate. We instead parse the failed line rather
47+
# than the progress indicator as the progress indicator may not be
48+
# aligned with the failure.
49+
failing_action = ninja_log[index].split("FAILED: ")[1]
4850
failure_log = []
4951
while (
5052
index < len(ninja_log)

.ci/generate_test_report_lib_test.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_find_failure_ninja_logs(self):
3939
self.assertEqual(
4040
failures[0],
4141
(
42-
"test/4.stamp",
42+
"touch test/4.stamp",
4343
dedent(
4444
"""\
4545
FAILED: touch test/4.stamp
@@ -77,7 +77,7 @@ def test_ninja_log_end(self):
7777
self.assertEqual(
7878
failures[0],
7979
(
80-
"test/3.stamp",
80+
"touch test/3.stamp",
8181
dedent(
8282
"""\
8383
FAILED: touch test/3.stamp
@@ -106,7 +106,7 @@ def test_ninja_log_multiple_failures(self):
106106
self.assertEqual(
107107
failures[0],
108108
(
109-
"test/2.stamp",
109+
"touch test/2.stamp",
110110
dedent(
111111
"""\
112112
FAILED: touch test/2.stamp
@@ -117,7 +117,7 @@ def test_ninja_log_multiple_failures(self):
117117
self.assertEqual(
118118
failures[1],
119119
(
120-
"test/4.stamp",
120+
"touch test/4.stamp",
121121
dedent(
122122
"""\
123123
FAILED: touch test/4.stamp
@@ -150,7 +150,7 @@ def test_ninja_log_runtimes_failure(self):
150150
self.assertEqual(
151151
failures[0],
152152
(
153-
"test/2.stamp",
153+
"touch test/2.stamp",
154154
dedent(
155155
"""\
156156
FAILED: touch test/2.stamp
@@ -159,6 +159,34 @@ def test_ninja_log_runtimes_failure(self):
159159
),
160160
)
161161

162+
# Test that we correctly handle cases where the FAILED: line does not
163+
# match up with the progress indicator.
164+
def test_ninja_log_mismatched_failed(self):
165+
failures = generate_test_report_lib.find_failure_in_ninja_logs(
166+
[
167+
[
168+
"[1/5] test/1.stamp",
169+
"[2/5] test/2.stamp",
170+
"ModuleNotFoundError: No module named 'mount_langley'",
171+
"FAILED: tools/check-langley",
172+
"Wow! This system is really broken!",
173+
"[5/5] test/5.stamp",
174+
]
175+
]
176+
)
177+
self.assertEqual(len(failures), 1)
178+
self.assertEqual(
179+
failures[0],
180+
(
181+
"tools/check-langley",
182+
dedent(
183+
"""\
184+
FAILED: tools/check-langley
185+
Wow! This system is really broken!"""
186+
),
187+
),
188+
)
189+
162190
def test_title_only(self):
163191
self.assertEqual(
164192
generate_test_report_lib.generate_report("Foo", 0, [], []),
@@ -448,15 +476,15 @@ def test_no_failures_multiple_build_failed_ninja_log(self):
448476
All tests passed but another part of the build **failed**. Click on a failure below to see the details.
449477
450478
<details>
451-
<summary>test/2.stamp</summary>
479+
<summary>touch test/2.stamp</summary>
452480
453481
```
454482
FAILED: touch test/2.stamp
455483
Wow! Be Kind!
456484
```
457485
</details>
458486
<details>
459-
<summary>test/4.stamp</summary>
487+
<summary>touch test/4.stamp</summary>
460488
461489
```
462490
FAILED: touch test/4.stamp

0 commit comments

Comments
 (0)