Bug 1050511 - Modify import of marionette harness to avoid a mismatch in assertRaises when running through mach. r=gps
authorChris Manchester <cmanchester@mozilla.com>
Fri, 10 Oct 2014 12:58:10 -0400
changeset 210012 51c57f6ffd344930333861fa623a023c4e5794ec
parent 210011 72af2eacba6553a55078db5f3a1f9dd939421e9b
child 210013 bbcaa290276118d0bd3e75613058510ae3eb19f4
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgps
bugs1050511
milestone35.0a1
Bug 1050511 - Modify import of marionette harness to avoid a mismatch in assertRaises when running through mach. r=gps
build/mach_bootstrap.py
testing/marionette/mach_commands.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -40,17 +40,16 @@ SEARCH_PATHS = [
     'dom/bindings/parser',
     'layout/tools/reftest',
     'other-licenses/ply',
     'xpcom/idl-parser',
     'testing',
     'testing/xpcshell',
     'testing/web-platform',
     'testing/web-platform/harness',
-    'testing/marionette/client',
     'testing/marionette/client/marionette',
     'testing/marionette/transport',
     'testing/mozbase/mozcrash',
     'testing/mozbase/mozdebug',
     'testing/mozbase/mozdevice',
     'testing/mozbase/mozfile',
     'testing/mozbase/mozhttpd',
     'testing/mozbase/mozlog',
--- a/testing/marionette/mach_commands.py
+++ b/testing/marionette/mach_commands.py
@@ -1,14 +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 __future__ import unicode_literals
 
+import imp
 import os
 import sys
 import argparse
 
 from mozlog.structured import commandline
 
 from mozbuild.base import (
     MachCommandBase,
@@ -31,17 +32,27 @@ VARIANT=eng ./build.sh
 '''
 
 # A parser that will accept structured logging commandline arguments.
 _parser = argparse.ArgumentParser()
 commandline.add_logging_group(_parser)
 
 def run_marionette(tests, b2g_path=None, emulator=None, testtype=None,
     address=None, binary=None, topsrcdir=None, **kwargs):
-    from marionette.runtests import (
+
+    # Import the harness directly and under a different name here to avoid
+    # "marionette" being importable from two locations when "testing/marionette/client"
+    # is on sys.path.
+    # See bug 1050511.
+    path = os.path.join(topsrcdir, 'testing/marionette/client/marionette/runtests.py')
+    with open(path, 'r') as fh:
+        imp.load_module('marionetteharness', fh, path,
+                        ('.py', 'r', imp.PY_SOURCE))
+
+    from marionetteharness import (
         MarionetteTestRunner,
         BaseMarionetteOptions,
         startTestRunner
     )
 
     parser = BaseMarionetteOptions()
     commandline.add_logging_group(parser)
     options, args = parser.parse_args()