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 616421 78a311d09419822156454d53d3fc77a16a31e835
parent 615935 388d81ed93fa640f91d155f36254667c734157cf
child 639466 7656d97e3ca37ff2086997577152a23cd8b4f017
push id70678
push userbmo:gps@mozilla.com
push dateThu, 27 Jul 2017 01:14:57 +0000
reviewersjimb
bugs1384665, 1377216
milestone56.0a1
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
testing/mach_commands.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -424,47 +424,58 @@ def executable_name(name):
 
 @CommandProvider
 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']
+        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')
         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
 
 @CommandProvider
 class JsapiTestsCommand(MachCommandBase):