Backed out changeset 2b3bda5a4744 (bug 975169) for Marionette-webapi failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 24 Feb 2014 15:04:53 -0500
changeset 170575 a3e92264b4eb231a2584269660a37fb23c14f825
parent 170574 1f7c3b10f48252cb66eeaf6ef95bfb6e8edf0451
child 170576 a15a762f7eefdd7c09ce04574a968c69b2817c5d
child 170669 e3daaa4c73dd1748533a330926b0811240c2fb08
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
bugs975169
milestone30.0a1
backs out2b3bda5a4744864bacbbdcba9bb9fe0e9e3d1b26
Backed out changeset 2b3bda5a4744 (bug 975169) for Marionette-webapi failures.
testing/marionette/client/marionette/runner/base.py
testing/marionette/client/setup.py
--- a/testing/marionette/client/marionette/runner/base.py
+++ b/testing/marionette/client/marionette/runner/base.py
@@ -37,26 +37,20 @@ class MarionetteTest(TestResult):
 
 class MarionetteTestResult(unittest._TextTestResult, TestResultCollection):
 
     resultClass = MarionetteTest
 
     def __init__(self, *args, **kwargs):
         self.marionette = kwargs.pop('marionette')
         TestResultCollection.__init__(self, 'MarionetteTest')
+        unittest._TextTestResult.__init__(self, *args, **kwargs)
         self.passed = 0
         self.testsRun = 0
         self.result_modifiers = [] # used by mixins to modify the result
-        pid = kwargs.pop('b2g_pid')
-        if pid:
-            bases = [b for b in self.__class__.__bases__]
-            bases.append(B2GTestResultMixin)
-            self.__class__.__bases__ = tuple(bases)
-            B2GTestResultMixin.__init__(self, b2g_pid=pid)
-        unittest._TextTestResult.__init__(self, *args, **kwargs)
 
     @property
     def skipped(self):
         return [t for t in self if t.result == 'SKIPPED']
 
     @skipped.setter
     def skipped(self, value):
         pass
@@ -241,40 +235,27 @@ class MarionetteTestResult(unittest._Tex
 
 class MarionetteTextTestRunner(unittest.TextTestRunner):
 
     resultclass = MarionetteTestResult
 
     def __init__(self, **kwargs):
         self.marionette = kwargs['marionette']
         self.capabilities = kwargs.pop('capabilities')
-        self.pre_run_functions = []
-        self.b2g_pid = None
         del kwargs['marionette']
-
-        if self.capabilities['device'] != 'desktop' and self.capabilities['b2g']:
-            def b2g_pre_run():
-                dm_type = os.environ.get('DM_TRANS', 'adb')
-                if dm_type == 'adb':
-                    self.b2g_pid = get_b2g_pid(get_dm(self.marionette))
-            self.pre_run_functions.append(b2g_pre_run)
-
         unittest.TextTestRunner.__init__(self, **kwargs)
 
     def _makeResult(self):
         return self.resultclass(self.stream,
                                 self.descriptions,
                                 self.verbosity,
-                                marionette=self.marionette,
-                                b2g_pid=self.b2g_pid)
+                                marionette=self.marionette)
 
     def run(self, test):
         "Run the given test case or test suite."
-        for pre_run_func in self.pre_run_functions:
-            pre_run_func()
         result = self._makeResult()
         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:
@@ -325,16 +306,50 @@ class MarionetteTextTestRunner(unittest.
             infos.append("unexpected successes=%d" % unexpectedSuccesses)
         if infos:
             self.stream.writeln(" (%s)" % (", ".join(infos),))
         else:
             self.stream.write("\n")
         return result
 
 
+class B2GMarionetteTestResult(MarionetteTestResult, B2GTestResultMixin):
+
+    def __init__(self, *args, **kwargs):
+        # stupid hack because _TextTestRunner doesn't accept **kwargs
+        b2g_pid = kwargs.pop('b2g_pid')
+        MarionetteTestResult.__init__(self, *args, **kwargs)
+        kwargs['b2g_pid'] = b2g_pid
+        B2GTestResultMixin.__init__(self, *args, **kwargs)
+ 
+
+class B2GMarionetteTextTestRunner(MarionetteTextTestRunner):
+
+    resultclass = B2GMarionetteTestResult
+
+    def __init__(self, **kwargs):
+        MarionetteTextTestRunner.__init__(self, **kwargs)
+        if self.capabilities['device'] != 'desktop':
+            self.resultclass = B2GMarionetteTestResult
+        self.b2g_pid = None
+
+    def _makeResult(self):
+        return self.resultclass(self.stream,
+                                self.descriptions,
+                                self.verbosity,
+                                marionette=self.marionette,
+                                b2g_pid=self.b2g_pid)
+
+    def run(self, test):
+        dm_type = os.environ.get('DM_TRANS', 'adb')
+        if dm_type == 'adb':
+            self.b2g_pid = get_b2g_pid(get_dm(self.marionette))
+        return super(B2GMarionetteTextTestRunner, self).run(test)
+
+
 class BaseMarionetteOptions(OptionParser):
     def __init__(self, **kwargs):
         OptionParser.__init__(self, **kwargs)
         self.parse_args_handlers = [] # Used by mixins
         self.verify_usage_handlers = [] # Used by mixins
         self.add_option('--autolog',
                         action='store_true',
                         dest='autolog',
@@ -744,16 +759,19 @@ class BaseMarionetteTestRunner(object):
         if not self.marionette:
             self.start_marionette()
             if self.emulator:
                 self.marionette.emulator.wait_for_homescreen(self.marionette)
             # Retrieve capabilities for later use
             if not self._capabilities:
                 self.capabilities
 
+        if self.capabilities['device'] != 'desktop':
+            self.textrunnerclass = B2GMarionetteTextTestRunner
+
         for test in tests:
             self.add_test(test)
 
         counter = self.repeat
         while counter >=0:
             round = self.repeat - counter
             if round > 0:
                 self.logger.info('\nREPEAT %d\n-------' % round)
--- a/testing/marionette/client/setup.py
+++ b/testing/marionette/client/setup.py
@@ -1,12 +1,12 @@
 import os
 from setuptools import setup, find_packages
 
-version = '0.7.5'
+version = '0.7.4'
 
 # get documentation from the README
 try:
     here = os.path.dirname(os.path.abspath(__file__))
     description = file(os.path.join(here, 'README.md')).read()
 except (OSError, IOError):
     description = ''