Bug 1284874 - Represent am command as one string in FennecRunner; r?ahal
When running the command for starting Fennec, quotation marks aren't
processed properly when the 'am' portion of the command is represented
with one string token per argument; the args must be joined into one string
instead.
Also add log message about command being run in BaseRunner.
MozReview-Commit-ID: KZLnOdu9UGq
--- a/testing/mozbase/mozrunner/mozrunner/base/device.py
+++ b/testing/mozbase/mozrunner/mozrunner/base/device.py
@@ -164,20 +164,20 @@ class FennecRunner(DeviceRunner):
def __init__(self, cmdargs=None, **kwargs):
super(FennecRunner, self).__init__(**kwargs)
self.cmdargs = cmdargs or []
@property
def command(self):
cmd = [self.app_ctx.adb]
if self.app_ctx.dm._deviceSerial:
- cmd.extend(['-s', self.app_ctx.dm._deviceSerial])
- cmd.append('shell')
+ cmd.extend(["-s", self.app_ctx.dm._deviceSerial])
+ cmd.append("shell")
app = "%s/org.mozilla.gecko.BrowserApp" % self.app_ctx.remote_process
- cmd.extend(['am', 'start', '-a', 'android.activity.MAIN', '-n', app])
- params = ['-no-remote', '-profile', self.app_ctx.remote_profile]
- params.extend(self.cmdargs)
- cmd.extend(['--es', 'args', '"%s"' % ' '.join(params)])
- # Append env variables in the form "--es env0 MOZ_CRASHREPORTER=1"
+ am_subcommand = ["am", "start", "-a", "android.activity.MAIN", "-n", app]
+ app_params = ["-no-remote", "-profile", self.app_ctx.remote_profile]
+ app_params.extend(self.cmdargs)
+ am_subcommand.extend(["--es", "args", "'%s'" % " ".join(app_params)])
+ # Append env variables in the form |--es env0 MOZ_CRASHREPORTER=1|
for (count, (k, v)) in enumerate(self._device_env.iteritems()):
- cmd.extend(["--es", "env" + str(count), k + "=" + v])
-
+ am_subcommand.extend(["--es", "env%d" % count, "%s=%s" % (k,v)])
+ cmd.append("%s" % " ".join(am_subcommand))
return cmd
--- a/testing/mozbase/mozrunner/mozrunner/base/runner.py
+++ b/testing/mozbase/mozrunner/mozrunner/base/runner.py
@@ -93,16 +93,19 @@ class BaseRunner(object):
# ensure the runner is stopped
self.stop()
# attach a debugger, if specified
if debug_args:
cmd = list(debug_args) + cmd
+ logger = get_default_logger()
+ if logger:
+ logger.info('Application command: %s' % ' '.join(cmd))
if interactive:
self.process_handler = subprocess.Popen(cmd, env=self.env)
# TODO: other arguments
else:
# this run uses the managed processhandler
self.process_handler = self.process_class(cmd, env=self.env, **self.process_args)
self.process_handler.run(self.timeout, self.output_timeout)