Bug 1384665 - Use virtualenv Python in `mach check-spidermonkey`; r=jimb
authorGregory Szorc <gps@mozilla.com>
Wed, 26 Jul 2017 18:02:51 -0700
changeset 419946 54f3aaacf9e6064fff4e644d78d40ec9693e5355
parent 419945 d2513137446a16ed71bf264439371b573d17bd89
child 419947 52ea7b299388407e5277060e78e945af081a37a8
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1384665, 1377216
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 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
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -424,47 +424,58 @@ 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']
+        jittest_cmd = [
+            python,
+            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):