Skip to content

Commit 244e0ef

Browse files
committed
Merge remote-tracking branch 'upstream/main' into users/kevinsala/omp-dyn-groupprivate-codegen-pr
2 parents a3cd7ef + ec620bf commit 244e0ef

File tree

5,774 files changed

+470671
-86052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,774 files changed

+470671
-86052
lines changed

.ci/generate_test_report_github.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,9 @@
44
"""Script to generate a build report for Github."""
55

66
import argparse
7-
import platform
87

98
import generate_test_report_lib
109

11-
def compute_platform_title() -> str:
12-
logo = ":window:" if platform.system() == "Windows" else ":penguin:"
13-
# On Linux the machine value is x86_64 on Windows it is AMD64.
14-
if platform.machine() == "x86_64" or platform.machine() == "AMD64":
15-
arch = "x64"
16-
else:
17-
arch = platform.machine()
18-
return f"{logo} {platform.system()} {arch} Test Results"
19-
2010

2111
if __name__ == "__main__":
2212
parser = argparse.ArgumentParser()
@@ -27,7 +17,9 @@ def compute_platform_title() -> str:
2717
args = parser.parse_args()
2818

2919
report = generate_test_report_lib.generate_report_from_files(
30-
compute_platform_title(), args.return_code, args.build_test_logs
20+
generate_test_report_lib.compute_platform_title(),
21+
args.return_code,
22+
args.build_test_logs,
3123
)
3224

3325
print(report)

.ci/generate_test_report_lib.py

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
"""Library to parse JUnit XML files and return a markdown report."""
55

6+
from typing import TypedDict, Optional
7+
import platform
8+
69
from junitparser import JUnitXml, Failure
710

11+
12+
# This data structure should match the definition in llvm-zorg in
13+
# premerge/advisor/advisor_lib.py
14+
# TODO(boomanaiden154): Drop the Optional here and switch to str | None when
15+
# we require Python 3.10.
16+
class FailureExplanation(TypedDict):
17+
name: str
18+
explained: bool
19+
reason: Optional[str]
20+
21+
822
SEE_BUILD_FILE_STR = "Download the build's log file to see the details."
923
UNRELATED_FAILURES_STR = (
1024
"If these failures are unrelated to your changes (for example "
@@ -41,10 +55,12 @@ def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
4155
# touch test/4.stamp
4256
#
4357
# 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]
58+
# indicator is sometimes the line before this ([4/5] test/4.stamp) and
59+
# will contain a pretty printed version of the target being built
60+
# (test/4.stamp) when accurate. We instead parse the failed line rather
61+
# than the progress indicator as the progress indicator may not be
62+
# aligned with the failure.
63+
failing_action = ninja_log[index].split("FAILED: ")[1]
4864
failure_log = []
4965
while (
5066
index < len(ninja_log)
@@ -80,16 +96,29 @@ def find_failure_in_ninja_logs(ninja_logs: list[list[str]]) -> list[tuple[str, s
8096
return failures
8197

8298

83-
def _format_ninja_failures(ninja_failures: list[tuple[str, str]]) -> list[str]:
84-
"""Formats ninja failures into summary views for the report."""
99+
def _format_failures(
100+
failures: list[tuple[str, str]], failure_explanations: dict[str, FailureExplanation]
101+
) -> list[str]:
102+
"""Formats failures into summary views for the report."""
85103
output = []
86-
for build_failure in ninja_failures:
104+
for build_failure in failures:
87105
failed_action, failure_message = build_failure
106+
failure_explanation = None
107+
if failed_action in failure_explanations:
108+
failure_explanation = failure_explanations[failed_action]
109+
output.append("<details>")
110+
if failure_explanation:
111+
output.extend(
112+
[
113+
f"<summary>{failed_action} (Likely Already Failing)</summary>" "",
114+
failure_explanation["reason"],
115+
"",
116+
]
117+
)
118+
else:
119+
output.extend([f"<summary>{failed_action}</summary>", ""])
88120
output.extend(
89121
[
90-
"<details>",
91-
f"<summary>{failed_action}</summary>",
92-
"",
93122
"```",
94123
failure_message,
95124
"```",
@@ -98,6 +127,7 @@ def _format_ninja_failures(ninja_failures: list[tuple[str, str]]) -> list[str]:
98127
)
99128
return output
100129

130+
101131
def get_failures(junit_objects) -> dict[str, list[tuple[str, str]]]:
102132
failures = {}
103133
for results in junit_objects:
@@ -129,12 +159,19 @@ def generate_report(
129159
ninja_logs: list[list[str]],
130160
size_limit=1024 * 1024,
131161
list_failures=True,
162+
failure_explanations_list: list[FailureExplanation] = [],
132163
):
133164
failures = get_failures(junit_objects)
134165
tests_run = 0
135166
tests_skipped = 0
136167
tests_failed = 0
137168

169+
failure_explanations: dict[str, FailureExplanation] = {}
170+
for failure_explanation in failure_explanations_list:
171+
if not failure_explanation["explained"]:
172+
continue
173+
failure_explanations[failure_explanation["name"]] = failure_explanation
174+
138175
for results in junit_objects:
139176
for testsuite in results:
140177
tests_run += testsuite.tests
@@ -173,7 +210,7 @@ def generate_report(
173210
"",
174211
]
175212
)
176-
report.extend(_format_ninja_failures(ninja_failures))
213+
report.extend(_format_failures(ninja_failures, failure_explanations))
177214
report.extend(
178215
[
179216
"",
@@ -209,18 +246,7 @@ def plural(num_tests):
209246

210247
for testsuite_name, failures in failures.items():
211248
report.extend(["", f"### {testsuite_name}"])
212-
for name, output in failures:
213-
report.extend(
214-
[
215-
"<details>",
216-
f"<summary>{name}</summary>",
217-
"",
218-
"```",
219-
output,
220-
"```",
221-
"</details>",
222-
]
223-
)
249+
report.extend(_format_failures(failures, failure_explanations))
224250
elif return_code != 0:
225251
# No tests failed but the build was in a failed state. Bring this to the user's
226252
# attention.
@@ -245,7 +271,7 @@ def plural(num_tests):
245271
"",
246272
]
247273
)
248-
report.extend(_format_ninja_failures(ninja_failures))
274+
report.extend(_format_failures(ninja_failures, failure_explanations))
249275

250276
if failures or return_code != 0:
251277
report.extend(["", UNRELATED_FAILURES_STR])
@@ -282,3 +308,13 @@ def load_info_from_files(build_log_files):
282308
def generate_report_from_files(title, return_code, build_log_files):
283309
junit_objects, ninja_logs = load_info_from_files(build_log_files)
284310
return generate_report(title, return_code, junit_objects, ninja_logs)
311+
312+
313+
def compute_platform_title() -> str:
314+
logo = ":window:" if platform.system() == "Windows" else ":penguin:"
315+
# On Linux the machine value is x86_64 on Windows it is AMD64.
316+
if platform.machine() == "x86_64" or platform.machine() == "AMD64":
317+
arch = "x64"
318+
else:
319+
arch = platform.machine()
320+
return f"{logo} {platform.system()} {arch} Test Results"

0 commit comments

Comments
 (0)