Bug 1278900 - Fix up the test package mach bootstrap script, r?armenzg draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 08 Jun 2016 10:41:13 -0400
changeset 377090 419cef5ea0a24dfca7caf0b46800e275ddab8279
parent 377089 73a38d9338eb404c921ca797c8f03dba4bc54240
child 377190 d7e5c624f1544c2b596d10141ed89d900486fb69
push id20747
push userahalberstadt@mozilla.com
push dateThu, 09 Jun 2016 16:41:51 +0000
reviewersarmenzg
bugs1278900
milestone50.0a1
Bug 1278900 - Fix up the test package mach bootstrap script, r?armenzg This is a bit of a hodge podge of small fixes that I needed to run |mach mochitest| on an interactive worker. Included: 1) Add some packages to SEARCH_PATHS that mochitest needs 2) Always add SEARCH_PATHS even if mach package is found 3) Don't try to register commands that don't exist (i.e it was in an unused test zip) MozReview-Commit-ID: BIXcCm4LzE2
testing/tools/mach_test_package_bootstrap.py
--- a/testing/tools/mach_test_package_bootstrap.py
+++ b/testing/tools/mach_test_package_bootstrap.py
@@ -2,20 +2,22 @@
 # 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 print_function, unicode_literals
 
 import os
 import platform
 import sys
-import time
 
 
 SEARCH_PATHS = [
+    'marionette',
+    'marionette/marionette/runner/mixins/browsermob-proxy-py',
+    'marionette/client',
     'mochitest',
     'mozbase/mozcrash',
     'mozbase/mozdebug',
     'mozbase/mozdevice',
     'mozbase/mozfile',
     'mozbase/mozhttpd',
     'mozbase/mozleak',
     'mozbase/mozlog',
@@ -25,16 +27,17 @@ SEARCH_PATHS = [
     'mozbase/mozrunner',
     'mozbase/mozsystemmonitor',
     'mozbase/mozinfo',
     'mozbase/mozscreenshot',
     'mozbase/moztest',
     'mozbase/mozversion',
     'mozbase/manifestparser',
     'tools/mach',
+    'tools/wptserve',
 ]
 
 # Individual files providing mach commands.
 MACH_MODULES = [
     'mochitest/mach_test_package_commands.py',
     'tools/mach/mach/commands/commandinfo.py',
 ]
 
@@ -59,40 +62,46 @@ CATEGORIES = {
         'short': 'Disabled',
         'long': 'The disabled commands are hidden by default. Use -v to display them. These commands are unavailable for your current context, run "mach <command>" to see why.',
         'priority': 0,
     }
 }
 
 
 def bootstrap(test_package_root):
+    test_package_root = os.path.abspath(test_package_root)
+
     # Ensure we are running Python 2.7+. We put this check here so we generate a
     # user-friendly error message rather than a cryptic stack trace on module
     # import.
     if sys.version_info[0] != 2 or sys.version_info[1] < 7:
         print('Python 2.7 or above (but not Python 3) is required to run mach.')
         print('You are running Python', platform.python_version())
         sys.exit(1)
 
-    try:
-        import mach.main
-    except ImportError:
-        sys.path[0:0] = [os.path.join(test_package_root, path) for path in SEARCH_PATHS]
-        import mach.main
+    sys.path[0:0] = [os.path.join(test_package_root, path) for path in SEARCH_PATHS]
+    import mach.main
 
     def populate_context(context, key=None):
+        if key is not None:
+            return
+
         context.package_root = test_package_root
         context.certs_dir = os.path.join(test_package_root, 'certs')
         context.bin_dir = os.path.join(test_package_root, 'bin')
         context.modules_dir = os.path.join(test_package_root, 'modules')
-        return context
 
     mach = mach.main.Mach(os.getcwd())
     mach.populate_context_handler = populate_context
 
     for category, meta in CATEGORIES.items():
         mach.define_category(category, meta['short'], meta['long'],
-            meta['priority'])
+                             meta['priority'])
 
     for path in MACH_MODULES:
-        mach.load_commands_from_file(os.path.join(test_package_root, path))
+        cmdfile = os.path.join(test_package_root, path)
+
+        # Depending on which test zips were extracted,
+        # the command module might not exist
+        if os.path.isfile(cmdfile):
+            mach.load_commands_from_file(cmdfile)
 
     return mach