Bug 887291 - Allow marionette test runner to pass command line arguments onto the application, r=jgriffin
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 07 Aug 2013 11:46:25 -0400
changeset 154610 46163186a53a715a37bcdbdf8836d4bc052b859c
parent 154609 5e519aedb9d1ab6afdaa3e75a2808f6ccbe84f74
child 154611 cbb253f535486f68ca852d1040e1ea476d8166f3
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs887291
milestone26.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 887291 - Allow marionette test runner to pass command line arguments onto the application, r=jgriffin
testing/marionette/client/marionette/geckoinstance.py
testing/marionette/client/marionette/marionette.py
testing/marionette/client/marionette/runtests.py
--- a/testing/marionette/client/marionette/geckoinstance.py
+++ b/testing/marionette/client/marionette/geckoinstance.py
@@ -13,21 +13,22 @@ class GeckoInstance(object):
     required_prefs = {"marionette.defaultPrefs.enabled": True,
                       "marionette.defaultPrefs.port": 2828,
                       "startup.homepage_welcome_url": "about:blank",
                       "browser.shell.checkDefaultBrowser": False,
                       "browser.startup.page": 0,
                       "browser.sessionstore.resume_from_crash": False,
                       "browser.warnOnQuit": False}
 
-    def __init__(self, host, port, bin, profile):
+    def __init__(self, host, port, bin, profile, app_args=None):
         self.marionette_host = host
         self.marionette_port = port
         self.bin = bin
         self.profile = profile
+        self.app_args = app_args or []
         self.runner = None
 
     def start(self):
         profile_path = self.profile
         profile_args = {"preferences": self.required_prefs}
         if not profile_path:
             runner_class = Runner
             profile_args["restore"] = False
@@ -36,17 +37,17 @@ class GeckoInstance(object):
             profile_args["path_from"] = profile_path
 
         self.gecko_log = os.path.abspath('gecko.log')
         if os.access(self.gecko_log, os.F_OK):
             os.remove(self.gecko_log)
         self.runner = runner_class.create(
             binary=self.bin,
             profile_args=profile_args,
-            cmdargs=['-no-remote', '-marionette'],
+            cmdargs=['-no-remote', '-marionette'] + self.app_args,
             kp_kwargs={
                 'processOutputLine': [NullOutput()],
                 'logfile': self.gecko_log})
         self.runner.start()
 
     def close(self):
         self.runner.stop()
         self.runner.cleanup()
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -193,24 +193,23 @@ class MultiActions(object):
 class Marionette(object):
 
     CONTEXT_CHROME = 'chrome'
     CONTEXT_CONTENT = 'content'
     TIMEOUT_SEARCH = 'implicit'
     TIMEOUT_SCRIPT = 'script'
     TIMEOUT_PAGE = 'page load'
 
-    def __init__(self, host='localhost', port=2828, app=None, bin=None,
+    def __init__(self, host='localhost', port=2828, app=None, app_args=None, bin=None,
                  profile=None, emulator=None, sdcard=None, emulatorBinary=None,
                  emulatorImg=None, emulator_res=None, gecko_path=None,
                  connectToRunningEmulator=False, homedir=None, baseurl=None,
                  noWindow=False, logcat_dir=None, busybox=None, symbols_path=None, timeout=None):
         self.host = host
         self.port = self.local_port = port
-        self.app = app
         self.bin = bin
         self.instance = None
         self.profile = profile
         self.session = None
         self.window = None
         self.emulator = None
         self.extra_emulators = []
         self.homedir = homedir
@@ -231,17 +230,17 @@ class Marionette(object):
                 try:
                     instance_class = geckoinstance.apps[app]
                 except KeyError:
                     msg = 'Application "%s" unknown (should be one of %s)'
                     raise NotImplementedError(msg % (app, geckoinstance.apps.keys()))
             else:
                 instance_class = geckoinstance.GeckoInstance
             self.instance = instance_class(host=self.host, port=self.port,
-                                           bin=self.bin, profile=self.profile)
+                                           bin=self.bin, profile=self.profile, app_args=app_args)
             self.instance.start()
             assert(self.wait_for_port())
 
         if emulator:
             self.emulator = Emulator(homedir=homedir,
                                      noWindow=self.noWindow,
                                      logcat_dir=self.logcat_dir,
                                      arch=emulator,
--- a/testing/marionette/client/marionette/runtests.py
+++ b/testing/marionette/client/marionette/runtests.py
@@ -205,28 +205,29 @@ class MarionetteTextTestRunner(unittest.
 
 
 class MarionetteTestRunner(object):
 
     textrunnerclass = MarionetteTextTestRunner
 
     def __init__(self, address=None, emulator=None, emulatorBinary=None,
                  emulatorImg=None, emulator_res='480x800', homedir=None,
-                 app=None, bin=None, profile=None, autolog=False, revision=None,
-                 logger=None, testgroup="marionette", noWindow=False,
+                 app=None, app_args=None, bin=None, profile=None, autolog=False,
+                 revision=None, logger=None, testgroup="marionette", noWindow=False,
                  logcat_dir=None, xml_output=None, repeat=0, gecko_path=None,
                  testvars=None, tree=None, type=None, device_serial=None,
                  symbols_path=None, timeout=None, es_servers=None, **kwargs):
         self.address = address
         self.emulator = emulator
         self.emulatorBinary = emulatorBinary
         self.emulatorImg = emulatorImg
         self.emulator_res = emulator_res
         self.homedir = homedir
         self.app = app
+        self.app_args = app_args or []
         self.bin = bin
         self.profile = profile
         self.autolog = autolog
         self.testgroup = testgroup
         self.revision = revision
         self.logger = logger
         self.noWindow = noWindow
         self.httpd = None
@@ -322,16 +323,17 @@ class MarionetteTestRunner(object):
             if self.address:
                 host, port = self.address.split(':')
             else:
                 host = 'localhost'
                 port = 2828
             self.marionette = Marionette(host=host,
                                          port=int(port),
                                          app=self.app,
+                                         app_args=self.app_args,
                                          bin=self.bin,
                                          profile=self.profile,
                                          baseurl=self.baseurl,
                                          timeout=self.timeout)
         elif self.address:
             host, port = self.address.split(':')
             try:
                 #establish a socket connection so we can vertify the data come back
@@ -691,16 +693,21 @@ class MarionetteTestOptions(OptionParser
         self.add_option('--homedir',
                         dest='homedir',
                         action='store',
                         help='home directory of emulator files')
         self.add_option('--app',
                         dest='app',
                         action='store',
                         help='application to use')
+        self.add_option('--app-arg',
+                        dest='app_args',
+                        action='append',
+                        default=[],
+                        help='specify a command line argument to be passed onto the application')
         self.add_option('--binary',
                         dest='bin',
                         action='store',
                         help='gecko executable to launch before running the test')
         self.add_option('--profile',
                         dest='profile',
                         action='store',
                         help='profile to use when launching the gecko process. if not passed, then a profile will be '