Bug 613109 - Make it possible to run a mochitest-* test suite with an extension installed; r=ted
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 18 Nov 2010 17:15:54 -0500
changeset 63585 e4311825a9c7
parent 63584 6eb93bfd55b7
child 63586 9f90513c5b2b
push id19245
push usereakhgari@mozilla.com
push date2011-03-23 21:40 +0000
treeherdermozilla-central@47af4dfc6d16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs613109
milestone2.2a1pre
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 613109 - Make it possible to run a mochitest-* test suite with an extension installed; r=ted
layout/tools/reftest/runreftest.py
testing/mochitest/runtests.py
--- a/layout/tools/reftest/runreftest.py
+++ b/layout/tools/reftest/runreftest.py
@@ -134,16 +134,17 @@ class RefTest(object):
     debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs,
         options.debuggerInteractive);
 
     profileDir = None
     try:
       profileDir = mkdtemp()
       self.createReftestProfile(options, profileDir)
       self.copyExtraFilesToProfile(options, profileDir)
+      self.installExtensionsToProfile(options, profileDir)
 
       # browser environment
       browserEnv = self.buildBrowserEnv(options, profileDir)
 
       self.registerExtension(browserEnv, options, profileDir)
 
       # then again to actually run reftest
       self.automation.log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
@@ -168,16 +169,23 @@ class RefTest(object):
     for f in options.extraProfileFiles:
       abspath = self.getFullPath(f)
       dest = os.path.join(profileDir, os.path.basename(abspath))
       if os.path.isdir(abspath):
         shutil.copytree(abspath, dest)
       else:
         shutil.copy(abspath, dest)
 
+  def installExtensionsToProfile(self, options, profileDir):
+    "Install the specified extensions on the command line to the testing profile."
+    for f in options.extensionsToInstall:
+      abspath = self.getFullPath(f)
+      extensionID = f[:f.rfind(".")]
+      self.automation.installExtension(abspath, profileDir, extensionID)
+
 
 class ReftestOptions(OptionParser):
 
   def __init__(self, automation):
     self._automation = automation
     OptionParser.__init__(self)
     defaults = {}
 
@@ -228,16 +236,23 @@ class ReftestOptions(OptionParser):
                     help = "file to log output to in addition to stdout")
     defaults["logFile"] = None
  
     self.add_option("--skip-slow-tests",
                     dest = "skipSlowTests", action = "store_true",
                     help = "skip tests marked as slow when running")
     defaults["skipSlowTests"] = False
 
+    self.add_option("--install-extension",
+                    action = "append", dest = "extensionsToInstall",
+                    help = "install the specified extension in the testing profile."
+                           "The extension file's name should be <id>.xpi where <id> is"
+                           "the extension's id as indicated in its install.rdf.")
+    defaults["extensionsToInstall"] = []
+
     self.set_defaults(**defaults)
 
 def main():
   automation = Automation()
   parser = ReftestOptions(automation)
   reftest = RefTest(automation)
 
   options, args = parser.parse_args()
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -202,16 +202,23 @@ class MochitestOptions(optparse.OptionPa
                            "(requires a debug build to be effective)")
     defaults["fatalAssertions"] = False
 
     self.add_option("--extra-profile-file",
                     action = "append", dest = "extraProfileFiles",
                     help = "copy specified files/dirs to testing profile")
     defaults["extraProfileFiles"] = []
 
+    self.add_option("--install-extension",
+                    action = "append", dest = "extensionsToInstall",
+                    help = "install the specified extension in the testing profile."
+                           "The extension file's name should be <id>.xpi where <id> is"
+                           "the extension's id as indicated in its install.rdf.")
+    defaults["extensionsToInstall"] = []
+
     self.add_option("--profile-path", action = "store",
                     type = "string", dest = "profilePath",
                     help = "Directory where the profile will be stored."
                            "This directory will be deleted after the tests are finished")
     defaults["profilePath"] = tempfile.mkdtemp()
 
     self.add_option("--use-vmware-recording",
                     action = "store_true", dest = "vmwareRecording",
@@ -488,16 +495,17 @@ class Mochitest(object):
     self.copyExtraFilesToProfile(options)
 
     # We only need special powers in non-chrome harnesses
     if (not options.browserChrome and
         not options.chrome and
         not options.a11y):
       self.installSpecialPowersExtension(options)
 
+    self.installExtensionsToProfile(options)
     return manifest
 
   def buildBrowserEnv(self, options):
     """ build the environment variables for the specific test and operating system """
     browserEnv = self.automation.environment(xrePath = options.xrePath)
 
     # These variables are necessary for correct application startup; change
     # via the commandline at your own risk.
@@ -755,16 +763,23 @@ overlay chrome://browser/content/browser
     for f in options.extraProfileFiles:
       abspath = self.getFullPath(f)
       dest = os.path.join(options.profilePath, os.path.basename(abspath))
       if os.path.isdir(abspath):
         shutil.copytree(abspath, dest)
       else:
         shutil.copy(abspath, dest)
 
+  def installExtensionsToProfile(self, options):
+    "Install the specified extensions on the command line to the testing profile."
+    for f in options.extensionsToInstall:
+      abspath = self.getFullPath(f)
+      extensionID = f[:f.rfind(".")]
+      self.automation.installExtension(abspath, options.profilePath, extensionID)
+
 def main():
   automation = Automation()
   mochitest = Mochitest(automation)
   parser = MochitestOptions(automation, mochitest.SCRIPT_DIRECTORY)
   options, args = parser.parse_args()
 
   options = parser.verifyOptions(options, mochitest)
   if options == None: