Bug 1393826 - [python-test] Make sure pytest errors get flagged by treeherder, r?davehunt
This is a quick and dirty hack to get treeherder to show pytest failures. Long term, we might
want to investigate using something like pytest-mozlog. But the benefit of this approach is
we get to keep pytest's fantastic default log format.
MozReview-Commit-ID: Gcsz6z8MeOi
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -200,16 +200,20 @@ class MachCommands(MachCommandBase):
def _line_handler(line):
if not file_displayed_test:
output = ('Ran' in line or 'collected' in line or
line.startswith('TEST-'))
if output:
file_displayed_test.append(True)
+ # Hack to make sure treeherder highlights pytest failures
+ if line.endswith('FAILED'):
+ line = line.replace('FAILED', 'TEST-UNEXPECTED-FAIL')
+
_log(line)
_log(test_path)
cmd = [self.virtualenv_manager.python_path, test_path]
env = os.environ.copy()
env[b'PYTHONDONTWRITEBYTECODE'] = b'1'
proc = ProcessHandler(cmd, env=env, processOutputLine=_line_handler, storeOutput=False)