From ac7433fc00061b7f14bf2490fb9126e77031b6b5 Mon Sep 17 00:00:00 2001 From: ahochheiden Date: Fri, 11 Feb 2022 18:04:18 +0000 Subject: [PATCH] Bug 1754726 - Add capturing for `stderr` when running Python Tests r=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 --- python/mach_commands.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/mach_commands.py b/python/mach_commands.py index 25f8e07a534a..99243a7c7b2a 100644 --- a/python/mach_commands.py +++ b/python/mach_commands.py @@ -318,7 +318,12 @@ def _run_python_test(command_context, test, jobs, verbose): 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 @@ -338,6 +343,7 @@ def _run_python_test(command_context, test, jobs, verbose): _log(line) if not file_displayed_test: + return_code = 1 _log( "TEST-UNEXPECTED-FAIL | No test output (missing mozunit.main() " "call?): {}".format(test["path"])