Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .ci/generate_test_report_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
# touch test/4.stamp
#
# index will point to the line that starts with Failed:. The progress
# indicator is the line before this ([4/5] test/4.stamp) and contains a pretty
# printed version of the target being built (test/4.stamp). We use this line
# and remove the progress information to get a succinct name for the target.
failing_action = ninja_log[index - 1].split("] ")[1]
# indicator is sometimes the line before this ([4/5] test/4.stamp) and
# will contain a pretty printed version of the target being built
# (test/4.stamp) when accurate. We instead parse the failed line rather
# than the progress indicator as the progress indicator may not be
# aligned with the failure.
failing_action = ninja_log[index].split("FAILED: ")[1]
failure_log = []
while (
index < len(ninja_log)
Expand Down
42 changes: 35 additions & 7 deletions .ci/generate_test_report_lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_find_failure_ninja_logs(self):
self.assertEqual(
failures[0],
(
"test/4.stamp",
"touch test/4.stamp",
dedent(
"""\
FAILED: touch test/4.stamp
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_ninja_log_end(self):
self.assertEqual(
failures[0],
(
"test/3.stamp",
"touch test/3.stamp",
dedent(
"""\
FAILED: touch test/3.stamp
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_ninja_log_multiple_failures(self):
self.assertEqual(
failures[0],
(
"test/2.stamp",
"touch test/2.stamp",
dedent(
"""\
FAILED: touch test/2.stamp
Expand All @@ -117,7 +117,7 @@ def test_ninja_log_multiple_failures(self):
self.assertEqual(
failures[1],
(
"test/4.stamp",
"touch test/4.stamp",
dedent(
"""\
FAILED: touch test/4.stamp
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_ninja_log_runtimes_failure(self):
self.assertEqual(
failures[0],
(
"test/2.stamp",
"touch test/2.stamp",
dedent(
"""\
FAILED: touch test/2.stamp
Expand All @@ -159,6 +159,34 @@ def test_ninja_log_runtimes_failure(self):
),
)

# Test that we correctly handle cases where the FAILED: line does not
# match up with the progress indicator.
def test_ninja_log_mismatched_failed(self):
failures = generate_test_report_lib.find_failure_in_ninja_logs(
[
[
"[1/5] test/1.stamp",
"[2/5] test/2.stamp",
"ModuleNotFoundError: No module named 'mount_langley'",
"FAILED: tools/check-langley",
"Wow! This system is really broken!",
"[5/5] test/5.stamp",
]
]
)
self.assertEqual(len(failures), 1)
self.assertEqual(
failures[0],
(
"tools/check-langley",
dedent(
"""\
FAILED: tools/check-langley
Wow! This system is really broken!"""
),
),
)

def test_title_only(self):
self.assertEqual(
generate_test_report_lib.generate_report("Foo", 0, [], []),
Expand Down Expand Up @@ -449,15 +477,15 @@ def test_no_failures_multiple_build_failed_ninja_log(self):
All tests passed but another part of the build **failed**. Click on a failure below to see the details.

<details>
<summary>test/2.stamp</summary>
<summary>touch test/2.stamp</summary>

```
FAILED: touch test/2.stamp
Wow! Be Kind!
```
</details>
<details>
<summary>test/4.stamp</summary>
<summary>touch test/4.stamp</summary>

```
FAILED: touch test/4.stamp
Expand Down