Bug 1384665 - Use virtualenv Python in mach check-spidermonkey; r=jimb

Recent changes in bug 1377216 introduced some new Python imports
to some SpiderMonkey test scripts. These modules likely won't be on
sys.path by default.

To ensure these Python processes always work, this commit changes
them to be executed with the Python binary from the build system's
virtualenv.

In the case of jit_test.py and jstests.py, we switch from relying on
the shebang Python (`/usr/bin/env python`). In other cases, we switch
from mach's python (essentially `which python2.7` or `python`).
Previously, some clients may have been using Python 3 via shebang
discovery. This change will force them to Python 2. This might be
unfortunate. But proper Python 3 support in mach and the build system
is a bit of a mess right now. I'd rather we just consistently use
the virtualenv Python because it is more well-defined and it
eliminates a class of bugs around the Python environment being
undefined.

MozReview-Commit-ID: 4NHzWisIgDC

--HG--
extra : rebase_source : cb79fe457daf7780aabcef902718429fdd5072a5
This commit is contained in:
Gregory Szorc 2017-07-26 18:02:51 -07:00
parent 413b71eafc
commit a9bab5de7c

View File

@ -429,21 +429,32 @@ class CheckSpiderMonkeyCommand(MachCommandBase):
def run_checkspidermonkey(self, **params):
import subprocess
import sys
self.virtualenv_manager.ensure()
python = self.virtualenv_manager.python_path
js = os.path.join(self.bindir, executable_name('js'))
print('Running jit-tests')
jittest_cmd = [os.path.join(self.topsrcdir, 'js', 'src', 'jit-test', 'jit_test.py'),
js, '--no-slow', '--jitflags=all']
jittest_cmd = [
python,
os.path.join(self.topsrcdir, 'js', 'src', 'jit-test', 'jit_test.py'),
js,
'--no-slow',
'--jitflags=all',
]
if params['valgrind']:
jittest_cmd.append('--valgrind')
jittest_result = subprocess.call(jittest_cmd)
print('running jstests')
jstest_cmd = [os.path.join(self.topsrcdir, 'js', 'src', 'tests', 'jstests.py'),
js, '--jitflags=all']
jstest_cmd = [
python,
os.path.join(self.topsrcdir, 'js', 'src', 'tests', 'jstests.py'),
js,
'--jitflags=all',
]
jstest_result = subprocess.call(jstest_cmd)
print('running jsapi-tests')
@ -451,15 +462,15 @@ class CheckSpiderMonkeyCommand(MachCommandBase):
jsapi_tests_result = subprocess.call(jsapi_tests_cmd)
print('running check-style')
check_style_cmd = [sys.executable, os.path.join(self.topsrcdir, 'config', 'check_spidermonkey_style.py')]
check_style_cmd = [python, os.path.join(self.topsrcdir, 'config', 'check_spidermonkey_style.py')]
check_style_result = subprocess.call(check_style_cmd, cwd=os.path.join(self.topsrcdir, 'js', 'src'))
print('running check-masm')
check_masm_cmd = [sys.executable, os.path.join(self.topsrcdir, 'config', 'check_macroassembler_style.py')]
check_masm_cmd = [python, os.path.join(self.topsrcdir, 'config', 'check_macroassembler_style.py')]
check_masm_result = subprocess.call(check_masm_cmd, cwd=os.path.join(self.topsrcdir, 'js', 'src'))
print('running check-js-msg-encoding')
check_js_msg_cmd = [sys.executable, os.path.join(self.topsrcdir, 'config', 'check_js_msg_encoding.py')]
check_js_msg_cmd = [python, os.path.join(self.topsrcdir, 'config', 'check_js_msg_encoding.py')]
check_js_msg_result = subprocess.call(check_js_msg_cmd, cwd=self.topsrcdir)
all_passed = jittest_result and jstest_result and jsapi_tests_result and check_style_result and check_masm_result and check_js_msg_result