Skip to content

Commit c1f6650

Browse files
committed
Merge branch 'main' into add-pkey-x86
2 parents 30b1d22 + 15bbdd1 commit c1f6650

File tree

10,129 files changed

+875306
-184299
lines changed

Some content is hidden

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

10,129 files changed

+875306
-184299
lines changed

.ci/generate_test_report_github.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88

99
import generate_test_report_lib
1010

11-
PLATFORM_TITLES = {
12-
"Windows": ":window: Windows x64 Test Results",
13-
"Linux": ":penguin: Linux x64 Test Results",
14-
}
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+
1520

1621
if __name__ == "__main__":
1722
parser = argparse.ArgumentParser()
@@ -22,7 +27,7 @@
2227
args = parser.parse_args()
2328

2429
report = generate_test_report_lib.generate_report_from_files(
25-
PLATFORM_TITLES[platform.system()], args.return_code, args.build_test_logs
30+
compute_platform_title(), args.return_code, args.build_test_logs
2631
)
2732

2833
print(report)

.ci/generate_test_report_lib.py

Lines changed: 31 additions & 21 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)
@@ -98,6 +100,23 @@ def _format_ninja_failures(ninja_failures: list[tuple[str, str]]) -> list[str]:
98100
)
99101
return output
100102

103+
def get_failures(junit_objects) -> dict[str, list[tuple[str, str]]]:
104+
failures = {}
105+
for results in junit_objects:
106+
for testsuite in results:
107+
for test in testsuite:
108+
if (
109+
not test.is_passed
110+
and test.result
111+
and isinstance(test.result[0], Failure)
112+
):
113+
if failures.get(testsuite.name) is None:
114+
failures[testsuite.name] = []
115+
failures[testsuite.name].append(
116+
(test.classname + "/" + test.name, test.result[0].text)
117+
)
118+
return failures
119+
101120

102121
# Set size_limit to limit the byte size of the report. The default is 1MB as this
103122
# is the most that can be put into an annotation. If the generated report exceeds
@@ -113,7 +132,7 @@ def generate_report(
113132
size_limit=1024 * 1024,
114133
list_failures=True,
115134
):
116-
failures = {}
135+
failures = get_failures(junit_objects)
117136
tests_run = 0
118137
tests_skipped = 0
119138
tests_failed = 0
@@ -124,18 +143,6 @@ def generate_report(
124143
tests_skipped += testsuite.skipped
125144
tests_failed += testsuite.failures
126145

127-
for test in testsuite:
128-
if (
129-
not test.is_passed
130-
and test.result
131-
and isinstance(test.result[0], Failure)
132-
):
133-
if failures.get(testsuite.name) is None:
134-
failures[testsuite.name] = []
135-
failures[testsuite.name].append(
136-
(test.classname + "/" + test.name, test.result[0].text)
137-
)
138-
139146
report = [f"# {title}", ""]
140147

141148
if tests_run == 0:
@@ -258,7 +265,7 @@ def plural(num_tests):
258265
return report
259266

260267

261-
def generate_report_from_files(title, return_code, build_log_files):
268+
def load_info_from_files(build_log_files):
262269
junit_files = [
263270
junit_file for junit_file in build_log_files if junit_file.endswith(".xml")
264271
]
@@ -271,6 +278,9 @@ def generate_report_from_files(title, return_code, build_log_files):
271278
ninja_logs.append(
272279
[log_line.strip() for log_line in ninja_log_file_handle.readlines()]
273280
)
274-
return generate_report(
275-
title, return_code, [JUnitXml.fromfile(p) for p in junit_files], ninja_logs
276-
)
281+
return [JUnitXml.fromfile(p) for p in junit_files], ninja_logs
282+
283+
284+
def generate_report_from_files(title, return_code, build_log_files):
285+
junit_objects, ninja_logs = load_info_from_files(build_log_files)
286+
return generate_report(title, return_code, junit_objects, ninja_logs)

.ci/generate_test_report_lib_test.py

Lines changed: 35 additions & 8 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, [], []),
@@ -407,7 +435,6 @@ def test_no_failures_multiple_build_failed_ninja_log(self):
407435
]
408436
],
409437
)
410-
print(test)
411438
self.assertEqual(
412439
generate_test_report_lib.generate_report(
413440
"Foo",
@@ -449,15 +476,15 @@ def test_no_failures_multiple_build_failed_ninja_log(self):
449476
All tests passed but another part of the build **failed**. Click on a failure below to see the details.
450477
451478
<details>
452-
<summary>test/2.stamp</summary>
479+
<summary>touch test/2.stamp</summary>
453480
454481
```
455482
FAILED: touch test/2.stamp
456483
Wow! Be Kind!
457484
```
458485
</details>
459486
<details>
460-
<summary>test/4.stamp</summary>
487+
<summary>touch test/4.stamp</summary>
461488
462489
```
463490
FAILED: touch test/4.stamp

.ci/metrics/metrics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
GITHUB_JOB_TO_TRACK = {
4141
"github_llvm_premerge_checks": {
4242
"Build and Test Linux": "premerge_linux",
43+
"Build and Test Linux AArch64": "premerge_linux_aarch64",
4344
"Build and Test Windows": "premerge_windows",
4445
},
4546
"github_libcxx_premerge_checks": {

.ci/monolithic-linux.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ start-group "ninja"
6666

6767
# Targets are not escaped as they are passed as separate arguments.
6868
ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
69+
cp ${BUILD_DIR}/.ninja_log ninja.ninja_log
6970

7071
if [[ "${runtime_targets}" != "" ]]; then
7172
start-group "ninja Runtimes"
7273

7374
ninja -C "${BUILD_DIR}" ${runtime_targets} |& tee ninja_runtimes.log
75+
cp ${BUILD_DIR}/.ninja_log ninja_runtimes.ninja_log
7476
fi
7577

7678
# Compiling runtimes with just-built Clang and running their tests
@@ -87,6 +89,7 @@ if [[ "${runtime_targets_needs_reconfig}" != "" ]]; then
8789

8890
ninja -C "${BUILD_DIR}" ${runtime_targets_needs_reconfig} \
8991
|& tee ninja_runtimes_needs_reconfig1.log
92+
cp ${BUILD_DIR}/.ninja_log ninja_runtimes_needs_reconig.ninja_log
9093

9194
start-group "CMake Runtimes Clang Modules"
9295

@@ -99,4 +102,5 @@ if [[ "${runtime_targets_needs_reconfig}" != "" ]]; then
99102

100103
ninja -C "${BUILD_DIR}" ${runtime_targets_needs_reconfig} \
101104
|& tee ninja_runtimes_needs_reconfig2.log
105+
cp ${BUILD_DIR}/.ninja_log ninja_runtimes_needs_reconfig2.ninja_log
102106
fi

.ci/monolithic-windows.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ runtimes_targets="${4}"
2323
start-group "CMake"
2424
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
2525

26-
export CC=cl
27-
export CXX=cl
26+
export CC=C:/clang/clang-msvc/bin/clang-cl.exe
27+
export CXX=C:/clang/clang-msvc/bin/clang-cl.exe
2828
export LD=link
2929

3030
# The CMAKE_*_LINKER_FLAGS to disable the manifest come from research
@@ -49,15 +49,18 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4949
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
5050
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
5151
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \
52+
-D CMAKE_CXX_FLAGS="-Wno-c++98-compat -Wno-c++14-compat -Wno-unsafe-buffer-usage -Wno-old-style-cast" \
5253
-D LLVM_ENABLE_RUNTIMES="${runtimes}"
5354

5455
start-group "ninja"
5556

5657
# Targets are not escaped as they are passed as separate arguments.
5758
ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
59+
cp ${BUILD_DIR}/.ninja_log ninja.ninja_log
5860

5961
if [[ "${runtime_targets}" != "" ]]; then
6062
start-group "ninja runtimes"
6163

6264
ninja -C "${BUILD_DIR}" -k 0 ${runtimes_targets} |& tee ninja_runtimes.log
65+
cp ${BUILD_DIR}/.ninja_log ninja_runtimes.ninja_log
6366
fi

.ci/premerge_advisor_explain.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Script for getting explanations from the premerge advisor."""
5+
6+
import argparse
7+
import os
8+
import platform
9+
import sys
10+
11+
import requests
12+
13+
import generate_test_report_lib
14+
15+
PREMERGE_ADVISOR_URL = (
16+
"http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/explain"
17+
)
18+
19+
20+
def main(commit_sha: str, build_log_files: list[str]):
21+
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
22+
build_log_files
23+
)
24+
test_failures = generate_test_report_lib.get_failures(junit_objects)
25+
current_platform = f"{platform.system()}-{platform.machine()}".lower()
26+
explanation_request = {
27+
"base_commit_sha": commit_sha,
28+
"platform": current_platform,
29+
"failures": [],
30+
}
31+
if test_failures:
32+
for _, failures in test_failures.items():
33+
for name, failure_messsage in failures:
34+
explanation_request["failures"].append(
35+
{"name": name, "message": failure_messsage}
36+
)
37+
else:
38+
ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs)
39+
for name, failure_message in ninja_failures:
40+
explanation_request["failures"].append(
41+
{"name": name, "message": failure_message}
42+
)
43+
advisor_response = requests.get(
44+
PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
45+
)
46+
if advisor_response.status_code == 200:
47+
print(advisor_response.json())
48+
else:
49+
print(advisor_response.reason)
50+
51+
52+
if __name__ == "__main__":
53+
parser = argparse.ArgumentParser()
54+
parser.add_argument("commit_sha", help="The base commit SHA for the test.")
55+
parser.add_argument(
56+
"build_log_files", help="Paths to JUnit report files and ninja logs.", nargs="*"
57+
)
58+
args = parser.parse_args()
59+
60+
# Skip looking for results on AArch64 for now because the premerge advisor
61+
# service is not available on AWS currently.
62+
if platform.machine() == "arm64":
63+
sys.exit(0)
64+
65+
main(args.commit_sha, args.build_log_files)

0 commit comments

Comments
 (0)