Bug 1555014 - Update wptreport formatter to support new mozlog test field; known_intermittent r=jgraham

Added support for the new known_intermittent test field in mozlog.structured to the WptreportFormatter
class. A test was added to check this field is recognised. The mozlog version was updated in the
requirements.txt for wpt. Capture was added to the mozlog init file, so that the module can be used
by mozlog consumers, such as wpt.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nikki Sharpley 2019-06-05 20:27:34 +00:00
parent 2f1b964b3b
commit 26fdbae6fa
2 changed files with 40 additions and 1 deletions

View File

@ -104,6 +104,8 @@ class WptreportFormatter(BaseFormatter):
subtest["status"] = data["status"]
if "expected" in data:
subtest["expected"] = data["expected"]
if "known_intermittent" in data:
subtest["known_intermittent"] = data["known_intermittent"]
if "message" in data:
subtest["message"] = replace_lone_surrogate(data["message"])
@ -114,6 +116,8 @@ class WptreportFormatter(BaseFormatter):
test["status"] = data["status"]
if "expected" in data:
test["expected"] = data["expected"]
if "known_intermittent" in data:
test["known_intermittent"] = data["known_intermittent"]
if "message" in data:
test["message"] = replace_lone_surrogate(data["message"])
if "reftest_screenshots" in data.get("extra", {}):

View File

@ -104,7 +104,9 @@ def test_wptreport_lone_surrogate_ucs2(capfd):
logger = structuredlog.StructuredLogger("test_a")
logger.add_handler(handlers.StreamHandler(output, WptreportFormatter()))
with mock.patch.object(wptreport, 'surrogate_replacement', wptreport.SurrogateReplacementUcs2()):
with mock.patch.object(wptreport,
'surrogate_replacement',
wptreport.SurrogateReplacementUcs2()):
# output a bunch of stuff
logger.suite_start(["test-id-1"]) # no run_info arg!
logger.test_start("test-id-1")
@ -131,3 +133,36 @@ def test_wptreport_lone_surrogate_ucs2(capfd):
subtest = test["subtests"][0]
assert subtest["name"] == u"Name with surrogateU+d800"
assert subtest["message"] == u"\U0001F601 U+de0aU+d83d \U0001f60a"
def test_wptreport_known_intermittent(capfd):
output = StringIO()
logger = structuredlog.StructuredLogger("test_a")
logger.add_handler(handlers.StreamHandler(output, WptreportFormatter()))
# output a bunch of stuff
logger.suite_start(["test-id-1"]) # no run_info arg!
logger.test_start("test-id-1")
logger.test_status("test-id-1",
"a-subtest",
status="FAIL",
expected="PASS",
known_intermittent=["FAIL"])
logger.test_end("test-id-1",
status="OK",)
logger.suite_end()
# check nothing got output to stdout/stderr
# (note that mozlog outputs exceptions during handling to stderr!)
captured = capfd.readouterr()
assert captured.out == ""
assert captured.err == ""
# check the actual output of the formatter
output.seek(0)
output_obj = json.load(output)
test = output_obj["results"][0]
assert test["status"] == u"OK"
subtest = test["subtests"][0]
assert subtest["expected"] == u"PASS"
assert subtest["known_intermittent"] == [u'FAIL']