Skip to content

Commit 77d4652

Browse files
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents 080ade0 + f8e80c5 commit 77d4652

File tree

3 files changed

+20
-61
lines changed

3 files changed

+20
-61
lines changed

.ci/generate_test_report_github.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
parser.add_argument("junit_files", help="Paths to JUnit report files.", nargs="*")
1717
args = parser.parse_args()
1818

19-
report, _ = generate_test_report_lib.generate_report_from_files(
20-
args.title, args.return_code, args.junit_files, None
19+
report = generate_test_report_lib.generate_report_from_files(
20+
args.title, args.return_code, args.junit_files
2121
)
2222

2323
print(report)

.ci/generate_test_report_lib.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ def generate_report(
1818
junit_objects,
1919
size_limit=1024 * 1024,
2020
list_failures=True,
21-
buildkite_info=None,
2221
):
2322
if not junit_objects:
2423
# Note that we do not post an empty report, therefore we can ignore a
2524
# non-zero return code in situations like this.
2625
#
2726
# If we were going to post a report, then yes, it would be misleading
2827
# to say we succeeded when the final return code was non-zero.
29-
return ("", "success")
28+
return ""
3029

3130
failures = {}
3231
tests_run = 0
@@ -52,12 +51,7 @@ def generate_report(
5251
)
5352

5453
if not tests_run:
55-
return ("", None)
56-
57-
style = "success"
58-
# Either tests failed, or all tests passed but something failed to build.
59-
if tests_failed or return_code != 0:
60-
style = "error"
54+
return ""
6155

6256
report = [f"# {title}", ""]
6357

@@ -73,22 +67,12 @@ def plural(num_tests):
7367
if tests_failed:
7468
report.append(f"* {tests_failed} {plural(tests_failed)} failed")
7569

76-
if buildkite_info is not None:
77-
log_url = (
78-
"https://buildkite.com/organizations/{BUILDKITE_ORGANIZATION_SLUG}/"
79-
"pipelines/{BUILDKITE_PIPELINE_SLUG}/builds/{BUILDKITE_BUILD_NUMBER}/"
80-
"jobs/{BUILDKITE_JOB_ID}/download.txt".format(**buildkite_info)
81-
)
82-
download_text = f"[Download]({log_url})"
83-
else:
84-
download_text = "Download"
85-
8670
if not list_failures:
8771
report.extend(
8872
[
8973
"",
9074
"Failed tests and their output was too large to report. "
91-
f"{download_text} the build's log file to see the details.",
75+
"Download the build's log file to see the details.",
9276
]
9377
)
9478
elif failures:
@@ -118,7 +102,7 @@ def plural(num_tests):
118102
"",
119103
"All tests passed but another part of the build **failed**.",
120104
"",
121-
f"{download_text} the build's log file to see the details.",
105+
"Download the build's log file to see the details.",
122106
]
123107
)
124108

@@ -141,16 +125,14 @@ def plural(num_tests):
141125
junit_objects,
142126
size_limit,
143127
list_failures=False,
144-
buildkite_info=buildkite_info,
145128
)
146129

147-
return report, style
130+
return report
148131

149132

150-
def generate_report_from_files(title, return_code, junit_files, buildkite_info):
133+
def generate_report_from_files(title, return_code, junit_files):
151134
return generate_report(
152135
title,
153136
return_code,
154137
[JUnitXml.fromfile(p) for p in junit_files],
155-
buildkite_info=buildkite_info,
156138
)

.ci/generate_test_report_lib_test.py

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def junit_from_xml(xml):
2020

2121
class TestReports(unittest.TestCase):
2222
def test_title_only(self):
23-
self.assertEqual(
24-
generate_test_report_lib.generate_report("Foo", 0, []), ("", "success")
25-
)
23+
self.assertEqual(generate_test_report_lib.generate_report("Foo", 0, []), "")
2624

2725
def test_no_tests_in_testsuite(self):
2826
self.assertEqual(
@@ -42,7 +40,7 @@ def test_no_tests_in_testsuite(self):
4240
)
4341
],
4442
),
45-
("", None),
43+
"",
4644
)
4745

4846
def test_no_failures(self):
@@ -70,8 +68,7 @@ def test_no_failures(self):
7068
# Foo
7169
7270
* 1 test passed"""
73-
),
74-
"success",
71+
)
7572
),
7673
)
7774

@@ -93,12 +90,6 @@ def test_no_failures_build_failed(self):
9390
)
9491
)
9592
],
96-
buildkite_info={
97-
"BUILDKITE_ORGANIZATION_SLUG": "organization_slug",
98-
"BUILDKITE_PIPELINE_SLUG": "pipeline_slug",
99-
"BUILDKITE_BUILD_NUMBER": "build_number",
100-
"BUILDKITE_JOB_ID": "job_id",
101-
},
10293
),
10394
(
10495
dedent(
@@ -109,11 +100,10 @@ def test_no_failures_build_failed(self):
109100
110101
All tests passed but another part of the build **failed**.
111102
112-
[Download](https://buildkite.com/organizations/organization_slug/pipelines/pipeline_slug/builds/build_number/jobs/job_id/download.txt) the build's log file to see the details.
103+
Download the build's log file to see the details.
113104
114105
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label."""
115-
),
116-
"error",
106+
)
117107
),
118108
)
119109

@@ -174,14 +164,12 @@ def test_report_single_file_single_testsuite(self):
174164
</details>
175165
176166
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label."""
177-
),
178-
"error",
167+
)
179168
),
180169
)
181170

182-
MULTI_SUITE_OUTPUT = (
183-
dedent(
184-
"""\
171+
MULTI_SUITE_OUTPUT = dedent(
172+
"""\
185173
# ABC and DEF
186174
187175
* 1 test passed
@@ -210,8 +198,6 @@ def test_report_single_file_single_testsuite(self):
210198
</details>
211199
212200
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label."""
213-
),
214-
"error",
215201
)
216202

217203
def test_report_single_file_multiple_testsuites(self):
@@ -320,8 +306,7 @@ def test_report_dont_list_failures(self):
320306
Failed tests and their output was too large to report. Download the build's log file to see the details.
321307
322308
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label."""
323-
),
324-
"error",
309+
)
325310
),
326311
)
327312

@@ -346,12 +331,6 @@ def test_report_dont_list_failures_link_to_log(self):
346331
)
347332
],
348333
list_failures=False,
349-
buildkite_info={
350-
"BUILDKITE_ORGANIZATION_SLUG": "organization_slug",
351-
"BUILDKITE_PIPELINE_SLUG": "pipeline_slug",
352-
"BUILDKITE_BUILD_NUMBER": "build_number",
353-
"BUILDKITE_JOB_ID": "job_id",
354-
},
355334
),
356335
(
357336
dedent(
@@ -360,11 +339,10 @@ def test_report_dont_list_failures_link_to_log(self):
360339
361340
* 1 test failed
362341
363-
Failed tests and their output was too large to report. [Download](https://buildkite.com/organizations/organization_slug/pipelines/pipeline_slug/builds/build_number/jobs/job_id/download.txt) the build's log file to see the details.
342+
Failed tests and their output was too large to report. Download the build's log file to see the details.
364343
365344
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label."""
366-
),
367-
"error",
345+
)
368346
),
369347
)
370348

@@ -403,7 +381,6 @@ def test_report_size_limit(self):
403381
Failed tests and their output was too large to report. Download the build's log file to see the details.
404382
405383
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label."""
406-
),
407-
"error",
384+
)
408385
),
409386
)

0 commit comments

Comments
 (0)