-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[CI] Refactor generate_test_report_lib to expose more functionality #163275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI] Refactor generate_test_report_lib to expose more functionality #163275
Conversation
Created using spr 1.3.7
@llvm/pr-subscribers-infrastructure Author: Aiden Grossman (boomanaiden154) ChangesThis is intended to be used in the premerge advisor. This makes it quite Full diff: https://github.com/llvm/llvm-project/pull/163275.diff 1 Files Affected:
diff --git a/.ci/generate_test_report_lib.py b/.ci/generate_test_report_lib.py
index 5026c292a7934..2d18932ace135 100644
--- a/.ci/generate_test_report_lib.py
+++ b/.ci/generate_test_report_lib.py
@@ -98,6 +98,23 @@ def _format_ninja_failures(ninja_failures: list[tuple[str, str]]) -> list[str]:
)
return output
+def get_failures(junit_objects) -> dict[str, list[tuple[str, str]]]:
+ failures = {}
+ for results in junit_objects:
+ for testsuite in results:
+ for test in testsuite:
+ if (
+ not test.is_passed
+ and test.result
+ and isinstance(test.result[0], Failure)
+ ):
+ if failures.get(testsuite.name) is None:
+ failures[testsuite.name] = []
+ failures[testsuite.name].append(
+ (test.classname + "/" + test.name, test.result[0].text)
+ )
+ return failures
+
# Set size_limit to limit the byte size of the report. The default is 1MB as this
# is the most that can be put into an annotation. If the generated report exceeds
@@ -113,7 +130,7 @@ def generate_report(
size_limit=1024 * 1024,
list_failures=True,
):
- failures = {}
+ failures = get_failures(junit_objects)
tests_run = 0
tests_skipped = 0
tests_failed = 0
@@ -124,18 +141,6 @@ def generate_report(
tests_skipped += testsuite.skipped
tests_failed += testsuite.failures
- for test in testsuite:
- if (
- not test.is_passed
- and test.result
- and isinstance(test.result[0], Failure)
- ):
- if failures.get(testsuite.name) is None:
- failures[testsuite.name] = []
- failures[testsuite.name].append(
- (test.classname + "/" + test.name, test.result[0].text)
- )
-
report = [f"# {title}", ""]
if tests_run == 0:
@@ -258,7 +263,7 @@ def plural(num_tests):
return report
-def generate_report_from_files(title, return_code, build_log_files):
+def load_info_from_files(build_log_files):
junit_files = [
junit_file for junit_file in build_log_files if junit_file.endswith(".xml")
]
@@ -271,6 +276,11 @@ def generate_report_from_files(title, return_code, build_log_files):
ninja_logs.append(
[log_line.strip() for log_line in ninja_log_file_handle.readlines()]
)
+ return [JUnitXml.fromfile(p) for p in junit_files], ninja_logs
+
+
+def generate_report_from_files(title, return_code, build_log_files):
+ junit_objects, ninja_logs = load_info_from_files(build_log_files)
return generate_report(
- title, return_code, [JUnitXml.fromfile(p) for p in junit_files], ninja_logs
+ title, return_code, junit_objects, ninja_logs
)
|
✅ With the latest revision this PR passed the Python code formatter. |
Created using spr 1.3.7
This is intended to be used in the premerge advisor. This makes it quite a bit easier to reuse for the future script to upload failure information to the premerge advisor. Pull Request: llvm#163275
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…tionality This is intended to be used in the premerge advisor. This makes it quite a bit easier to reuse for the future script to upload failure information to the premerge advisor. Reviewers: DavidSpickett, cmtice Reviewed By: DavidSpickett, cmtice Pull Request: llvm/llvm-project#163275
This is intended to be used in the premerge advisor. This makes it quite a bit easier to reuse for the future script to upload failure information to the premerge advisor. Reviewers: DavidSpickett, cmtice Reviewed By: DavidSpickett, cmtice Pull Request: llvm#163275
This is intended to be used in the premerge advisor. This makes it quite
a bit easier to reuse for the future script to upload failure information to
the premerge advisor.