Bug 1567264 - [mozlog] Support log errors in the errorsummary and mach formatter r=jgraham

Differential Revision: https://phabricator.services.mozilla.com/D39547

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2019-07-29 15:16:22 +00:00
Родитель 2094ef2928
Коммит e3e6ea6d8e
2 изменённых файлов: 22 добавлений и 2 удалений

Просмотреть файл

@ -172,6 +172,7 @@ class MachFormatter(base.BaseFormatter):
count = summary['counts']
logs = summary['unexpected_logs']
intermittent_logs = summary['intermittent_logs']
harness_errors = summary['harness_errors']
rv = [
"",
@ -214,7 +215,7 @@ class MachFormatter(base.BaseFormatter):
rv.append(" {}: {} ({})".format(
key, sum(count[key]['unexpected'].values()), status_str))
# Format status
# Format intermittents
if intermittents > 0:
heading = "Known Intermittent Results"
rv.extend(["", self.color_formatter.heading(heading),
@ -233,9 +234,12 @@ class MachFormatter(base.BaseFormatter):
assert "subtest" not in data
rv.append(self._format_status(test, data).rstrip())
if not any(count[key]["unexpected"] for key in ('test', 'subtest', 'assert')):
# Format status
testfailed = any(count[key]["unexpected"] for key in ('test', 'subtest', 'assert'))
if not testfailed and not harness_errors:
rv.append(self.color_formatter.log_test_status_pass("OK"))
else:
# Format test failures
heading = "Unexpected Results"
rv.extend(["", self.color_formatter.heading(heading),
self.color_formatter.heading("-" * len(heading))])
@ -253,6 +257,11 @@ class MachFormatter(base.BaseFormatter):
assert "subtest" not in data
rv.append(self._format_status(test, data).rstrip())
# Format harness errors
if harness_errors:
for data in harness_errors:
rv.append(self.log(data))
return "\n".join(rv)
def test_start(self, data):

Просмотреть файл

@ -126,6 +126,7 @@ class SummaryHandler(LogHandler):
},
'unexpected_logs': OrderedDict(),
'intermittent_logs': OrderedDict(),
'harness_errors': [],
}
def test_start(self, data):
@ -184,3 +185,13 @@ class SummaryHandler(LogHandler):
count['assert']['unexpected']['fail'] += 1
else:
count['assert']['unexpected']['pass'] += 1
def log(self, data):
if not self.current_suite:
return
logs = self.current['harness_errors']
level = data.get("level").upper()
if level in ("CRITICAL", "ERROR"):
logs.append(data)