Bug 1562083 - explicitly insert sys.path to env for use in subprocess for python3 mozprocess unit tests r=jmaher

Differential Revision: https://phabricator.services.mozilla.com/D36681

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Edwin Gao 2019-07-03 17:52:19 +00:00
parent ba0b132304
commit 4760b99320
5 changed files with 51 additions and 9 deletions

View file

@ -8,7 +8,7 @@ job-defaults:
worker-type:
by-platform:
linux64.*: t-linux-xlarge
macosx1010-64.*: t-osx-1010
macosx1014-64.*: t-osx-1014
windows10-64.*: t-win10-64
worker:
by-platform:
@ -44,7 +44,7 @@ mach:
description: python/mach unit tests
platform:
- linux64/opt
- macosx1010-64/opt
- macosx1014-64/opt
- windows10-64/opt
python-version: [2, 3]
treeherder:
@ -118,7 +118,7 @@ mozbase:
description: testing/mozbase unit tests
platform:
- linux64/opt
- macosx1010-64/opt
- macosx1014-64/opt
- windows10-64/opt
python-version: [2, 3]
treeherder:
@ -148,7 +148,7 @@ mozlint:
description: python/mozlint unit tests
platform:
- linux64/opt
- macosx1010-64/opt
- macosx1014-64/opt
- windows10-64/opt
python-version: [2]
treeherder:

View file

@ -43,9 +43,14 @@ defaults = {
def configure_mach(config, job, taskdesc):
run = job['run']
command_prefix = 'cd $GECKO_PATH && ./mach '
additional_prefix = []
if job['worker-type'].endswith('1014'):
command_prefix = 'cd $GECKO_PATH && LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 ./mach '
additional_prefix = [
'LC_ALL=en_US.UTF-8',
'LANG=en_US.UTF-8'
]
command_prefix = ' '.join(['cd $GECKO_PATH'] + additional_prefix + ['&& ./mach '])
mach = run['mach']
if isinstance(mach, dict):

View file

@ -7,6 +7,7 @@ import time
import unittest
import proctest
import signal
import sys
import mozunit
@ -50,9 +51,17 @@ class ProcTestKill(proctest.ProcTest):
"""Process is started, we use a deep process tree, we let it spawn
for a bit, we kill it"""
myenv = None
# On macosx1014, subprocess fails to find `six` when run with python3.
# This ensures that subprocess first looks to sys.path to find `six`.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1562083
if sys.platform == 'darwin' and sys.version_info[0] > 2:
myenv = os.environ.copy()
myenv['PYTHONPATH'] = ':'.join(sys.path)
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_deep.ini"],
cwd=here)
cwd=here, env=myenv)
p.run()
# Let the tree spawn a bit, before attempting to kill
time.sleep(3)
@ -75,9 +84,17 @@ class ProcTestKill(proctest.ProcTest):
"""Process is started, we use a broad process tree, we let it spawn
for a bit, we kill it"""
myenv = None
# On macosx1014, subprocess fails to find `six` when run with python3.
# This ensures that subprocess first looks to sys.path to find `six`.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1562083
if sys.platform == 'darwin' and sys.version_info[0] > 2:
myenv = os.environ.copy()
myenv['PYTHONPATH'] = ':'.join(sys.path)
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_broad.ini"],
cwd=here)
cwd=here, env=myenv)
p.run()
# Let the tree spawn a bit, before attempting to kill
time.sleep(3)

View file

@ -4,6 +4,7 @@
from __future__ import absolute_import
import os
import sys
import mozunit
@ -25,9 +26,19 @@ class ProcTestMisc(proctest.ProcTest):
def timeout_handler():
self.assertEqual(p.proc.poll(), None)
p.kill()
myenv = None
# On macosx1014, subprocess fails to find `six` when run with python3.
# This ensures that subprocess first looks to sys.path to find `six`.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1562083
if sys.platform == 'darwin' and sys.version_info[0] > 2:
myenv = os.environ.copy()
myenv['PYTHONPATH'] = ':'.join(sys.path)
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_waittimeout.ini"],
cwd=here,
env=myenv,
onTimeout=(timeout_handler,),
kill_on_timeout=False)
p.run(timeout=1)

View file

@ -4,6 +4,7 @@ from __future__ import absolute_import
import os
import signal
import sys
import mozinfo
import mozunit
@ -42,9 +43,17 @@ class ProcTestWait(proctest.ProcTest):
""" Process is started, runs but we time out waiting on it
to complete
"""
myenv = None
# On macosx1014, subprocess fails to find `six` when run with python3.
# This ensures that subprocess first looks to sys.path to find `six`.
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1562083
if sys.platform == 'darwin' and sys.version_info[0] > 2:
myenv = os.environ.copy()
myenv['PYTHONPATH'] = ':'.join(sys.path)
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_waittimeout.ini"],
cwd=here)
cwd=here, env=myenv)
p.run(timeout=10)
p.wait()