8000 Fix junit writing bug introduced in #16388 (#16417) · python/mypy@285519c · GitHub
[go: up one dir, main page]

Skip to content

Commit 285519c

Browse files
authored
Fix junit writing bug introduced in #16388 (#16417)
#16388 introduced a bug where, with `--junit-format=global`, the junit file would indicate an error (with no message) even if everything passed. That was because `_generate_junit_contents` would check if `messages_by_file` was empty or not to determine if there were failures, but with `--junit-format=global` we'd pass in a dictionary of the form `{None: all_messages}`; `all_messages` would be empty, but the resulting dictionary wouldn't be. The fix is to pass in an empty dictionary if there are no messages. I've tested manually with `--junit-format=global` and `--junit-format=per_file` in the successful case to make sure the files are written correctly now.
1 parent 544e6ce commit 285519c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

mypy/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,12 @@ def maybe_write_junit_xml(
15041504
py_version = f"{options.python_version[0]}_{options.python_version[1]}"
15051505
if options.junit_format == "global":
15061506
util.write_junit_xml(
1507-
td, serious, {None: all_messages}, options.junit_xml, py_version, options.platform
1507+
td,
1508+
serious,
1509+
{None: all_messages} if all_messages else {},
1510+
options.junit_xml,
1511+
py_version,
1512+
options.platform,
15081513
)
15091514
else:
15101515
# per_file

mypyc/build.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ def emit_messages(options: Options, messages: list[str], dt: float, serious: boo
106106
if options.junit_xml:
107107
py_version = f"{options.python_version[0]}_{options.python_version[1]}"
108108
write_junit_xml(
109-
dt, serious, {None: messages}, options.junit_xml, py_version, options.platform
109+
dt,
110+
serious,
111+
{None: messages} if messages else {},
112+
options.junit_xml,
113+
py_version,
114+
options.platform,
110115
)
111116
if messages:
112117
print("\n".join(messages))

0 commit comments

Comments
 (0)
0