Bug 1462489 - Use test addons from dist/xpi-stage when running mochitests locally. r=ahal
☠☠ backed out by aca4b4275042 ☠ ☠
authorChris Manchester <cmanchester@mozilla.com>
Wed, 30 May 2018 15:21:39 -0700
changeset 474778 3cd6a8ee8f66404844c0d17092182cdc563085e7
parent 474777 dfed23857ceadea9cfd762992a128ab9307ba364
child 474779 daa33716b140073f243c88ec1ea7b197a91e7caf
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1462489
milestone62.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 1462489 - Use test addons from dist/xpi-stage when running mochitests locally. r=ahal MozReview-Commit-ID: IoaxxjtJLhX
testing/mochitest/mochitest_options.py
testing/mochitest/runtests.py
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -748,17 +748,26 @@ class MochitestArguments(ArgumentContain
             if build_obj:
                 possible.insert(0, os.path.join(build_obj.topobjdir, '_tests', 'modules'))
 
             for p in possible:
                 if os.path.isdir(p):
                     options.testingModulesDir = p
                     break
 
+        # Paths to specialpowers and mochijar from the tests zip.
+        options.stagedAddons = [
+            os.path.join(here, 'extensions', 'specialpowers'),
+            os.path.join(here, 'mochijar'),
+        ]
         if build_obj:
+            options.stagedAddons = [
+                os.path.join(build_obj.distdir, 'xpi-stage', 'specialpowers'),
+                os.path.join(build_obj.distdir, 'xpi-stage', 'mochijar'),
+            ]
             plugins_dir = os.path.join(build_obj.distdir, 'plugins')
             if os.path.isdir(plugins_dir) and plugins_dir not in options.extraProfileFiles:
                 options.extraProfileFiles.append(plugins_dir)
 
         # Even if buildbot is updated, we still want this, as the path we pass in
         # to the app must be absolute and have proper slashes.
         if options.testingModulesDir is not None:
             options.testingModulesDir = os.path.normpath(
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -833,17 +833,16 @@ def update_mozinfo():
     mozinfo.find_and_update_from_json(*dirs)
 
 
 class MochitestDesktop(object):
     """
     Mochitest class for desktop firefox.
     """
     oldcwd = os.getcwd()
-    mochijar = os.path.join(SCRIPT_DIR, 'mochijar')
 
     # Path to the test script on the server
     TEST_PATH = "tests"
     NESTED_OOP_TEST_PATH = "nested_oop"
     CHROME_PATH = "redirect.html"
 
     certdbNew = False
     sslTunnel = None
@@ -851,19 +850,20 @@ class MochitestDesktop(object):
     mediaDevices = None
 
     patternFiles = {}
 
     # XXX use automation.py for test name to avoid breaking legacy
     # TODO: replace this with 'runtests.py' or 'mochitest' or the like
     test_name = 'automation.py'
 
-    def __init__(self, flavor, logger_options, quiet=False):
+    def __init__(self, flavor, logger_options, staged_addons=None, quiet=False):
         update_mozinfo()
         self.flavor = flavor
+        self.staged_addons = staged_addons
         self.server = None
         self.wsserver = None
         self.websocketProcessBridge = None
         self.sslTunnel = None
         self.manifest = None
         self.tests_by_manifest = defaultdict(list)
         self.prefs_by_manifest = defaultdict(set)
         self._active_tests = None
@@ -1316,21 +1316,16 @@ toolbar#nav-bar {
   background-image: none !important;
 }
 """
         with open(os.path.join(options.profilePath, "userChrome.css"), "a") as chromeFile:
             chromeFile.write(chrome)
 
         manifest = self.writeChromeManifest(options)
 
-        if not os.path.isdir(self.mochijar):
-            self.log.error(
-                "TEST-UNEXPECTED-FAIL | invalid setup: missing mochikit extension")
-            return None
-
         return manifest
 
     def getExtensionsToInstall(self, options):
         "Return a list of extensions to install in the profile"
         extensions = []
         appDir = options.app[
             :options.app.rfind(
                 os.sep)] if options.app else options.utilityPath
@@ -2253,20 +2248,24 @@ toolbar#nav-bar {
                 # start marionette and kick off the tests
                 marionette_args = marionette_args or {}
                 self.marionette = Marionette(**marionette_args)
                 self.marionette.start_session()
 
                 # install specialpowers and mochikit addons
                 addons = Addons(self.marionette)
 
-                addons.install(create_zip(
-                    os.path.join(here, 'extensions', 'specialpowers')
-                ))
-                addons.install(create_zip(self.mochijar))
+                if self.staged_addons:
+                    for addon_path in self.staged_addons:
+                        if not os.path.isdir(addon_path):
+                            self.log.error(
+                                "TEST-UNEXPECTED-FAIL | invalid setup: missing extension at %s" %
+                                addon_path)
+                            return 1, self.lastTestSeen
+                        addons.install(create_zip(addon_path))
 
                 self.execute_start_script()
 
                 # an open marionette session interacts badly with mochitest,
                 # delete it until we figure out why.
                 self.marionette.delete_session()
                 del self.marionette
 
@@ -3061,17 +3060,18 @@ toolbar#nav-bar {
 
 def run_test_harness(parser, options):
     parser.validate(options)
 
     logger_options = {
         key: value for key, value in vars(options).iteritems()
         if key.startswith('log') or key == 'valgrind'}
 
-    runner = MochitestDesktop(options.flavor, logger_options, quiet=options.quiet)
+    runner = MochitestDesktop(options.flavor, logger_options, options.stagedAddons,
+                              quiet=options.quiet)
 
     if hasattr(options, 'log'):
         delattr(options, 'log')
 
     options.runByManifest = False
     if options.flavor in ('plain', 'browser', 'chrome'):
         options.runByManifest = True