From 778826e8f7d8f3a914eb237e409cabfe9ff3d1f9 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Fri, 14 Oct 2011 08:53:06 -0700 Subject: [PATCH] Bug 688330 - 'Make special-powers install method a little less special'. r=ted. --- testing/mochitest/runtests.py | 49 ++++++++++----------- testing/mochitest/specialpowers/Makefile.in | 7 +-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index b14e9ff409a..7e92d663afe 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -515,21 +515,11 @@ class Mochitest(object): """ return self.getFullPath(logFile) - def installSpecialPowersExtension(self, options): - """ install the Special Powers extension for special testing capabilities """ - extensionSource = os.path.normpath(os.path.join(self.SCRIPT_DIRECTORY, "specialpowers")) - self.automation.log.info("INFO | runtests.py | Installing extension at %s to %s." % - (extensionSource, options.profilePath)) - - self.automation.installExtension(extensionSource, options.profilePath, "special-powers@mozilla.org") - self.automation.log.info("INFO | runtests.py | Done installing extension.") - def buildProfile(self, options): """ create the profile and add optional chrome bits and files if requested """ self.automation.initializeProfile(options.profilePath, options.extraPrefs, useServerLocations = True) manifest = self.addChromeToProfile(options) self.copyExtraFilesToProfile(options) - self.installSpecialPowersExtension(options) self.installExtensionsToProfile(options) return manifest @@ -850,24 +840,33 @@ overlay chrome://navigator/content/navigator.xul chrome://mochikit/content/brows self.automation.log.warning("WARNING | runtests.py | Failed to copy %s to profile", abspath) continue + def installExtensionFromPath(self, options, path, extensionID = None): + extensionPath = self.getFullPath(path) + + self.automation.log.info("INFO | runtests.py | Installing extension at %s to %s." % + (extensionPath, options.profilePath)) + self.automation.installExtension(extensionPath, options.profilePath, + extensionID) + def installExtensionsToProfile(self, options): - "Install application distributed extensions and specified on the command line ones to testing profile." - # Install distributed extensions, if application has any. - distExtDir = os.path.join(options.app[ : options.app.rfind(os.sep)], "distribution", "extensions") - if os.path.isdir(distExtDir): - for f in os.listdir(distExtDir): - self.automation.installExtension(os.path.join(distExtDir, f), options.profilePath) + "Install special testing extensions, application distributed extensions, and specified on the command line ones to testing profile." + extensionDirs = [ + # Extensions distributed with the test harness. + os.path.normpath(os.path.join(self.SCRIPT_DIRECTORY, "extensions")), + # Extensions distributed with the application. + os.path.join(options.app[ : options.app.rfind(os.sep)], "distribution", "extensions") + ] - # Install custom extensions. - for f in options.extensionsToInstall: - if f.endswith(os.sep): - f = f[:-1] + for extensionDir in extensionDirs: + if os.path.isdir(extensionDir): + for dirEntry in os.listdir(extensionDir): + path = os.path.join(extensionDir, dirEntry) + if os.path.isdir(path) or (os.path.isfile(path) and path.endswith(".xpi")): + self.installExtensionFromPath(options, path) - extensionPath = self.getFullPath(f) - - self.automation.log.info("INFO | runtests.py | Installing extension at %s to %s." % - (extensionPath, options.profilePath)) - self.automation.installExtension(extensionPath, options.profilePath) + # Install custom extensions passed on the command line. + for path in options.extensionsToInstall: + self.installExtensionFromPath(options, path) def main(): automation = Automation() diff --git a/testing/mochitest/specialpowers/Makefile.in b/testing/mochitest/specialpowers/Makefile.in index a9c6ef82443..7dafbf26619 100644 --- a/testing/mochitest/specialpowers/Makefile.in +++ b/testing/mochitest/specialpowers/Makefile.in @@ -54,12 +54,13 @@ EXTRA_COMPONENTS = components/SpecialPowersObserver.js XPI_NAME=specialpowers -DEST_DIR=testing/mochitest - # Used in install.rdf USE_EXTENSION_MANIFEST=1 +TEST_EXTENSIONS_DIR = $(DEPTH)/_tests/testing/mochitest/extensions + include $(topsrcdir)/config/rules.mk libs:: - (cd $(DIST)/xpi-stage && tar $(TAR_CREATE_FLAGS) - specialpowers) | (cd $(DEPTH)/_tests/$(DEST_DIR) && tar -xf -) + $(MKDIR) -p $(TEST_EXTENSIONS_DIR) + (cd $(DIST)/xpi-stage && tar $(TAR_CREATE_FLAGS) - $(XPI_NAME)) | (cd $(TEST_EXTENSIONS_DIR) && tar -xf -)