Bug 1338534 - [mozlog] Indicate unexpected pass with the correct status. r?ahal draft
authorDave Hunt <dhunt@mozilla.com>
Tue, 14 Feb 2017 23:09:28 +0000
changeset 485057 1960789da0cf58aa7df5da0a0a0698a38e43da77
parent 485056 6c5f52c5c839f50597cffc7dce60f02cbbb8db5e
child 545910 f5db22279f189f329bd6d5cb57596f474cfaad08
push id45612
push userdhunt@mozilla.com
push dateThu, 16 Feb 2017 01:41:44 +0000
reviewersahal
bugs1338534
milestone54.0a1
Bug 1338534 - [mozlog] Indicate unexpected pass with the correct status. r?ahal Unexpected passes can cause failures in pytest when the expected failures are set to strict. When we're logging these we want to indicate that the correct outcome. MozReview-Commit-ID: 8VoR6CTrynY
testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py
--- a/testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py
+++ b/testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py
@@ -77,16 +77,20 @@ class MozLog(object):
         if report.failed:
             status = 'FAIL' if report.when == 'call' else 'ERROR'
         if report.skipped:
             status = 'SKIP' if not hasattr(report, 'wasxfail') else 'FAIL'
         if report.longrepr is not None:
             if isinstance(report.longrepr, basestring):
                 # When using pytest-xdist, longrepr is serialised as a str
                 message = stack = report.longrepr
+                if report.longrepr.startswith('[XPASS(strict)]'):
+                    # Strict expected failures have an outcome of failed when
+                    # they unexpectedly pass.
+                    expected, status = ('FAIL', 'PASS')
             else:
                 try:
                     # For failures, longrepr is a ReprExceptionInfo
                     crash = report.longrepr.reprcrash
                     message = "{0} (line {1})".format(crash.message, crash.lineno)
                     stack = report.longrepr.reprtraceback
                 except AttributeError:
                     # For skips, longrepr is a tuple of (file, lineno, reason)