Bug 1284874 - Represent am command as one string in FennecRunner; r?ahal draft
authorMaja Frydrychowicz <mjzffr@gmail.com>
Mon, 25 Jul 2016 20:40:36 -0400
changeset 405501 1f9f10f77a9539b8dfa3eda7da93c0dfb1401a4a
parent 405457 7963ebdd52b93f96b812eff2eab8d94097147b9c
child 405502 88e7b1227df6ca8498d9f861ee8af53e32a25ba9
push id27507
push usermjzffr@gmail.com
push dateThu, 25 Aug 2016 15:12:45 +0000
reviewersahal
bugs1284874
milestone51.0a1
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
testing/mozbase/mozrunner/mozrunner/base/device.py
testing/mozbase/mozrunner/mozrunner/base/runner.py
--- 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)