Bug 1011428 - Fix structured log machformatter unexpected counts when running tests more than once, r=ahal

This commit is contained in:
James Graham 2014-05-21 16:36:38 +01:00
parent fed5a056a1
commit 23102ca6c1

View File

@ -21,6 +21,7 @@ class BaseMachFormatter(base.BaseFormatter):
self.write_interval = write_interval
self.write_times = write_times
self.status_buffer = {}
self.has_unexpected = {}
self.last_time = None
def __call__(self, data):
@ -55,6 +56,11 @@ class BaseMachFormatter(base.BaseFormatter):
subtests = self._get_subtest_data(data)
unexpected = subtests["unexpected"] + (1 if "expected" in data else 0)
#Reset the counts to 0
test = self._get_test_id(data)
self.status_buffer[test] = {"count": 0, "unexpected": 0, "pass": 0}
self.has_unexpected[test] = bool(unexpected)
return "Harness status %s%s. Subtests passed %i/%i. Unexpected %i" % (
data["status"], expected_str, subtests["pass"],
subtests["count"], unexpected)
@ -141,13 +147,13 @@ class MachTerminalFormatter(BaseMachFormatter):
if self.terminal is None:
return s
subtests = self._get_subtest_data(data)
test = self._get_test_id(data)
color = None
len_action = len(data["action"])
if data["action"] == "test_end":
if "expected" not in data and subtests["unexpected"] == 0:
if "expected" not in data and not self.has_unexpected[test]:
color = self.terminal.green
else:
color = self.terminal.red