Bug 1323770 - Moztest should forward correct test result. r=ahal a=test-only
authorHenrik Skupin <mail@hskupin.info>
Wed, 21 Dec 2016 11:19:36 +0100
changeset 366117 c57768314ac5046680ada6798ce46138c27f115a
parent 366116 286cc5f7a92de651814fa733f8f54081d6cfaff3
child 366118 94b956158413a846c1388816b8b596e22ea1515b
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal, test-only
bugs1323770
milestone52.0a2
Bug 1323770 - Moztest should forward correct test result. r=ahal a=test-only Registered callback handlers for tests should receive the correct test status when the test has been finished, and not always "Error". This change allows those callbacks to run specific code for individual test results, eg. only do screenshots for failures. MozReview-Commit-ID: FfbCRR0Jvjb
testing/mozbase/moztest/moztest/adapters/unit.py
testing/mozbase/moztest/setup.py
--- a/testing/mozbase/moztest/moztest/adapters/unit.py
+++ b/testing/mozbase/moztest/moztest/adapters/unit.py
@@ -129,49 +129,52 @@ class StructuredTestResult(TextTestResul
         self.logger.test_end(test.id(),
                              "ERROR",
                              message=self._extract_err_message(err),
                              expected="PASS",
                              stack=self._extract_stacktrace(err, test),
                              extra=extra)
 
     def addFailure(self, test, err):
-        extra = self.call_callbacks(test, "ERROR")
+        extra = self.call_callbacks(test, "FAIL")
         extra.update(self._get_class_method_name(test))
         self.logger.test_end(test.id(),
                              "FAIL",
                              message=self._extract_err_message(err),
                              expected="PASS",
                              stack=self._extract_stacktrace(err, test),
                              extra=extra)
 
     def addSuccess(self, test):
         extra = self._get_class_method_name(test)
-        self.logger.test_end(test.id(), "PASS", expected="PASS", extra=extra)
+        self.logger.test_end(test.id(),
+                             "PASS",
+                             expected="PASS",
+                             extra=extra)
 
     def addExpectedFailure(self, test, err):
-        extra = self.call_callbacks(test, "ERROR")
+        extra = self.call_callbacks(test, "FAIL")
         extra.update(self._get_class_method_name(test))
         self.logger.test_end(test.id(),
                              "FAIL",
                              message=self._extract_err_message(err),
                              expected="FAIL",
                              stack=self._extract_stacktrace(err, test),
                              extra=extra)
 
     def addUnexpectedSuccess(self, test):
-        extra = self.call_callbacks(test, "ERROR")
+        extra = self.call_callbacks(test, "PASS")
         extra.update(self._get_class_method_name(test))
         self.logger.test_end(test.id(),
                              "PASS",
                              expected="FAIL",
                              extra=extra)
 
     def addSkip(self, test, reason):
-        extra = self.call_callbacks(test, "ERROR")
+        extra = self.call_callbacks(test, "SKIP")
         extra.update(self._get_class_method_name(test))
         self.logger.test_end(test.id(),
                              "SKIP",
                              message=reason,
                              expected="PASS",
                              extra=extra)
 
 
--- a/testing/mozbase/moztest/setup.py
+++ b/testing/mozbase/moztest/setup.py
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from setuptools import setup, find_packages
 
-PACKAGE_VERSION = '0.7'
+PACKAGE_VERSION = '0.8'
 
 # dependencies
 deps = ['mozinfo']
 
 setup(name='moztest',
       version=PACKAGE_VERSION,
       description="Package for storing and outputting Mozilla test results",
       long_description="see http://mozbase.readthedocs.org/",