Bug 1059478 - [mozrunner] Fix environment handling in DeviceRunner; r=ahal
authorJulien Pagès <j.parkouss@gmail.com>
Tue, 16 Jun 2015 07:10:24 +0200
changeset 279820 ee270cc8a287630e9264bf2dbb97e97d0100d295
parent 279819 658e6dd34f360ff370883557a09dc5d65cf5a5fb
child 279821 9a3fa532721bc3af5afe95bf7468a30640e1bbb5
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1059478
milestone41.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 1059478 - [mozrunner] Fix environment handling in DeviceRunner; r=ahal
testing/mozbase/mozrunner/mozrunner/base/device.py
--- a/testing/mozbase/mozrunner/mozrunner/base/device.py
+++ b/testing/mozbase/mozrunner/mozrunner/base/device.py
@@ -28,40 +28,43 @@ class DeviceRunner(BaseRunner):
             'NSPR_LOG_MODULES': 'signaling:5,mtransport:5,datachannel:5,jsep:5,MediaPipelineFactory:5',
             'R_LOG_LEVEL': '6',
             'R_LOG_DESTINATION': 'stderr',
             'R_LOG_VERBOSE': '1',
             'NO_EM_RESTART': '1', }
 
     def __init__(self, device_class, device_args=None, **kwargs):
         process_log = tempfile.NamedTemporaryFile(suffix='pidlog')
-        self._env = dict(self.env)
-        self._env['MOZ_PROCESS_LOG'] = process_log.name
-        self._env.update(kwargs.pop('env', {}) or {})
+        # the env will be passed to the device, it is not a *real* env
+        self._device_env = dict(DeviceRunner.env)
+        self._device_env['MOZ_PROCESS_LOG'] = process_log.name
+        # be sure we do not pass env to the parent class ctor
+        env = kwargs.pop('env', None)
+        if env:
+            self._device_env.update(env)
 
         process_args = {'stream': sys.stdout,
                         'processOutputLine': self.on_output,
                         'onFinish': self.on_finish,
                         'onTimeout': self.on_timeout }
         process_args.update(kwargs.get('process_args') or {})
 
         kwargs['process_args'] = process_args
-        kwargs['env'] = {}
         BaseRunner.__init__(self, **kwargs)
 
         device_args = device_args or {}
         self.device = device_class(**device_args)
 
     @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')
-        for k, v in self._env.iteritems():
+        for k, v in self._device_env.iteritems():
             cmd.append('%s=%s' % (k, v))
         cmd.append(self.app_ctx.remote_binary)
         return cmd
 
     def start(self, *args, **kwargs):
         if isinstance(self.device, Emulator) and not self.device.connected:
             self.device.start()
         self.device.connect()
@@ -70,23 +73,17 @@ class DeviceRunner(BaseRunner):
         # TODO: this doesn't work well when the device is running but dropped
         # wifi for some reason. It would be good to probe the state of the device
         # to see if we have the homescreen running, or something, before waiting here
         self.device.wait_for_net()
 
         if not self.device.wait_for_net():
             raise Exception("Network did not come up when starting device")
 
-        # In this case we need to pass in env as part of the command.
-        # Make this empty so BaseRunner doesn't pass anything into the
-        # process class.
-        self._env = self.env
-        self.env = None
         BaseRunner.start(self, *args, **kwargs)
-        self.env = self._env
 
         timeout = 10 # seconds
         starttime = datetime.datetime.now()
         while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
             if self.is_running():
                 break
             time.sleep(1)
         else: