Bug 1323770 - Moztest should forward correct test result. draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 21 Dec 2016 11:19:36 +0100
changeset 454407 c0781ab0f563f7a0fb907c2728cb7c387bba592a
parent 454351 143bb4b9249e528e658f6ccc449991794b8675f8
child 454408 d2dcace560603d691f2d3345b7b05ae7bb93908c
push id39919
push userbmo:hskupin@gmail.com
push dateThu, 29 Dec 2016 08:23:35 +0000
bugs1323770
milestone53.0a1
Bug 1323770 - Moztest should forward correct test result. 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/",