Skip to content

Commit ca6a05a

Browse files
[CI] Allow Explaining Failures Where LLVM Root Dir Differs
The postsubmit and premerge CI setups build LLVM inside different directories due to how Github Actions sets things up. Use a regex to eliminate the differences so we can explain away failures that only differ due to the path. Most test cases seem to have the file path printed in the failure message. Reviewers: dschuff, lnihlen, cmtice, dwblaikie, gburgessiv, Keenuts Reviewed By: Keenuts, dwblaikie Pull Request: #645
1 parent 3ae62e0 commit ca6a05a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

premerge/advisor/advisor_lib.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import time
33
import sqlite3
44
import logging
5+
import re
6+
57
import git_utils
68

79

@@ -70,9 +72,17 @@ def setup_db(db_path: str) -> sqlite3.Connection:
7072
return connection
7173

7274

75+
def _canonicalize_failures(failures: list[TestFailure]):
76+
for failure in failures:
77+
failure["message"] = re.sub(
78+
r"\/home\/.*\/llvm-project", "llvm-project", failure["message"]
79+
)
80+
81+
7382
def upload_failures(
7483
failure_info: FailureUpload, db_connection: sqlite3.Connection, repository_path: str
7584
):
85+
_canonicalize_failures(failure_info["failures"])
7686
failures = []
7787
for failure in failure_info["failures"]:
7888
failures.append(
@@ -181,6 +191,7 @@ def explain_failures(
181191
repository_path: str,
182192
db_connection: sqlite3.Connection,
183193
) -> list[FailureExplanation]:
194+
_canonicalize_failures(explanation_request["failures"])
184195
explanations = []
185196
for test_failure in explanation_request["failures"]:
186197
commit_index = git_utils.get_commit_index(

premerge/advisor/advisor_lib_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,23 @@ def test_explain_head_within_range(self):
242242
],
243243
)
244244

245+
# Test that we can explain test failures where the llvm-project root is
246+
# located in a different path.
247+
def test_explain_different_root_path(self):
248+
self.assertListEqual(
249+
self._get_explained_failures(
250+
failure_message="/home/_w/llvm-project/test1/test1.ll failed",
251+
prev_failure_failure_message="/home/gha/llvm-project/test1/test1.ll failed",
252+
),
253+
[
254+
{
255+
"name": "a.ll",
256+
"explained": True,
257+
"reason": "This test is already failing at the base commit.",
258+
}
259+
],
260+
)
261+
245262
# Test that we do not explain away a failure at head if the only matching
246263
# failure information comes from a PR.
247264
def test_no_explain_different_source_type(self):

0 commit comments

Comments
 (0)