Bug 777842 - make Marionette Python2.6 compatible, r=dburns
authorJonathan Griffin <jgriffin@mozilla.com>
Fri, 10 Aug 2012 17:04:28 -0700
changeset 102230 bac11eca1505e57b24c7e1cfafef12b29bfe7644
parent 102229 762b97255eed8c0504ac5ef7a4dafdf9bbba502f
child 102231 cdb3c9eb8070d10441fe2b8d21e913df0e37b67e
push id23272
push useremorley@mozilla.com
push dateTue, 14 Aug 2012 12:52:48 +0000
treeherdermozilla-central@d9183f015df8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdburns
bugs777842
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 777842 - make Marionette Python2.6 compatible, r=dburns
testing/marionette/client/marionette/runtests.py
--- a/testing/marionette/client/marionette/runtests.py
+++ b/testing/marionette/client/marionette/runtests.py
@@ -22,20 +22,20 @@ try:
     from mozhttpd import iface, MozHttpd
 except ImportError:
     print "manifestparser or mozhttpd not found!  Please install mozbase:\n"
     print "\tgit clone git://github.com/mozilla/mozbase.git"
     print "\tpython setup_development.py\n"
     import sys
     sys.exit(1)
 
-
 from marionette import Marionette
 from marionette_test import MarionetteJSTestCase
 
+
 class MarionetteTestResult(unittest._TextTestResult):
 
     def __init__(self, *args):
         super(MarionetteTestResult, self).__init__(*args)
         self.passed = 0
         self.perfdata = None
         self.tests_passed = []
 
@@ -84,18 +84,20 @@ class MarionetteTextTestRunner(unittest.
     resultclass = MarionetteTestResult
 
     def _makeResult(self):
         return self.resultclass(self.stream, self.descriptions, self.verbosity)
 
     def run(self, test):
         "Run the given test case or test suite."
         result = self._makeResult()
-        result.failfast = self.failfast
-        result.buffer = self.buffer
+        if hasattr(self, 'failfast'):
+            result.failfast = self.failfast
+        if hasattr(self, 'buffer'):
+            result.buffer = self.buffer
         startTime = time.time()
         startTestRun = getattr(result, 'startTestRun', None)
         if startTestRun is not None:
             startTestRun()
         try:
             test(result)
         finally:
             stopTestRun = getattr(result, 'stopTestRun', None)
@@ -465,42 +467,51 @@ class MarionetteTestRunner(object):
 
         assembly = doc.createElement('assembly')
         assembly.setAttribute('name', 'Tests')
         assembly.setAttribute('time', str(self.elapsedtime))
         assembly.setAttribute('total', str(sum([results.testsRun for
                                                     results in results_list])))
         assembly.setAttribute('passed', str(sum([results.passed for
                                                      results in results_list])))
-        assembly.setAttribute('failed', str(sum([len(results.failures) +
-                                                 len(results.errors) +
-                                                 len(results.unexpectedSuccesses)
+
+        def failed_count(results):
+            count = len(results.failures) + len(results.errors)
+            if hasattr(results, 'unexpectedSuccesses'):
+                count += len(results.unexpectedSuccesses)
+            return count
+
+        assembly.setAttribute('failed', str(sum([failed_count(results)
                                                  for results in results_list])))
-        assembly.setAttribute('skipped', str(sum([len(results.skipped) +
-                                                  len(results.expectedFailures)
-                                                  for results in results_list])))
+        if hasattr(results, 'skipped'):
+            assembly.setAttribute('skipped', str(sum([len(results.skipped) +
+                                                      len(results.expectedFailures)
+                                                      for results in results_list])))
 
         for results in results_list:
             classes = {} # str -> xml class element
 
             for tup in results.errors:
                 _extract_xml(*tup, result='Fail')
 
             for tup in results.failures:
                 _extract_xml(*tup, result='Fail')
 
-            for test in results.unexpectedSuccesses:
-                # unexpectedSuccesses is a list of Testcases only, no tuples
-                _extract_xml(test, text='TEST-UNEXPECTED-PASS', result='Fail')
+            if hasattr(results, 'unexpectedSuccesses'):
+                for test in results.unexpectedSuccesses:
+                    # unexpectedSuccesses is a list of Testcases only, no tuples
+                    _extract_xml(test, text='TEST-UNEXPECTED-PASS', result='Fail')
 
-            for tup in results.skipped:
-                _extract_xml(*tup, result='Skip')
+            if hasattr(results, 'skipped'):
+                for tup in results.skipped:
+                    _extract_xml(*tup, result='Skip')
 
-            for tup in results.expectedFailures:
-                _extract_xml(*tup, result='Skip')
+            if hasattr(results, 'expectedFailures'):
+                for tup in results.expectedFailures:
+                    _extract_xml(*tup, result='Skip')
 
             for test in results.tests_passed:
                 _extract_xml(test)
 
             for cls in classes.itervalues():
                 assembly.appendChild(cls)
 
         doc.appendChild(assembly)