Skip to content

Commit

Permalink
Bug 1754726 - Add capturing for stderr when running Python Tests r=…
Browse files Browse the repository at this point in the history
…ahal

Since stdout is being piped, redirecting stderr to stdout causes it
to end up in the same pipe interleaved, which is what we want.

Also added a non-zero return code to be set when there is no test output.

Differential Revision: https://phabricator.services.mozilla.com/D138481
  • Loading branch information
ahochheiden committed Feb 11, 2022
1 parent e3dadbf commit ac7433f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion python/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,12 @@ def _log(line):
env["PYTHONDONTWRITEBYTECODE"] = "1"

result = subprocess.run(
cmd, env=env, stdout=subprocess.PIPE, universal_newlines=True, encoding="UTF-8"
cmd,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
encoding="UTF-8",
)

return_code = result.returncode
Expand All @@ -338,6 +343,7 @@ def _log(line):
_log(line)

if not file_displayed_test:
return_code = 1
_log(
"TEST-UNEXPECTED-FAIL | No test output (missing mozunit.main() "
"call?): {}".format(test["path"])
Expand Down

0 comments on commit ac7433f

Please sign in to comment.