Skip to content

Commit 6a12b43

Browse files
committed
[ci] Fix error when no junit files are passed to report generator
This resulted in the style being None and despite the report being empty as well, we tried to send it to the agent and Python can't send None as an argument. To fix this return "success" style and also check whether the report has any content before calling the agent.
1 parent 9a844a3 commit 6a12b43

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

.ci/generate_test_report.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,8 @@ def test_report_size_limit(self):
309309
# If include failures is False, total number of test will be reported but their names
310310
# and output will not be.
311311
def _generate_report(title, junit_objects, size_limit=1024 * 1024, list_failures=True):
312-
style = None
313-
314312
if not junit_objects:
315-
return ("", style)
313+
return ("", "success")
316314

317315
failures = {}
318316
tests_run = 0
@@ -403,22 +401,23 @@ def generate_report(title, junit_files):
403401

404402
report, style = generate_report(args.title, args.junit_files)
405403

406-
p = subprocess.Popen(
407-
[
408-
"buildkite-agent",
409-
"annotate",
410-
"--context",
411-
args.context,
412-
"--style",
413-
style,
414-
],
415-
stdin=subprocess.PIPE,
416-
stderr=subprocess.PIPE,
417-
universal_newlines=True,
418-
)
404+
if report:
405+
p = subprocess.Popen(
406+
[
407+
"buildkite-agent",
408+
"annotate",
409+
"--context",
410+
args.context,
411+
"--style",
412+
style,
413+
],
414+
stdin=subprocess.PIPE,
415+
stderr=subprocess.PIPE,
416+
universal_newlines=True,
417+
)
419418

420-
# The report can be larger than the buffer for command arguments so we send
421-
# it over stdin instead.
422-
_, err = p.communicate(input=report)
423-
if p.returncode:
424-
raise RuntimeError(f"Failed to send report to buildkite-agent:\n{err}")
419+
# The report can be larger than the buffer for command arguments so we send
420+
# it over stdin instead.
421+
_, err = p.communicate(input=report)
422+
if p.returncode:
423+
raise RuntimeError(f"Failed to send report to buildkite-agent:\n{err}")

0 commit comments

Comments
 (0)