Bug 1384665 - Use virtualenv Python in `mach check-spidermonkey`; r?jimb draft
authorGregory Szorc <gps@mozilla.com>
Wed, 26 Jul 2017 18:02:51 -0700
changeset 616415 df0fc298f875a1192c66c9e5212c191ade3f3946
parent 615935 388d81ed93fa640f91d155f36254667c734157cf
child 639460 63278d010a84b4cc2633bdb4d43a840cb100b926
push id70672
push userbmo:gps@mozilla.com
push dateThu, 27 Jul 2017 01:09:05 +0000
bugs1384665, 1377216
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 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 for jstests.py. 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. MozReview-Commit-ID: 4NHzWisIgDC
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -426,45 +426,52 @@ def executable_name(name):
 class CheckSpiderMonkeyCommand(MachCommandBase):
     @Command('check-spidermonkey', category='testing', description='Run SpiderMonkey tests (JavaScript engine).')
     @CommandArgument('--valgrind', action='store_true', help='Run jit-test suite with valgrind flag')
     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']
         if params['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')
         jsapi_tests_cmd = [os.path.join(self.bindir, executable_name('jsapi-tests'))]
         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
         return all_passed
 class JsapiTestsCommand(MachCommandBase):