[PATCH 1 of 3] run-tests: quote PYTHON when spawning a subprocess

Matt Harbison mharbison72 at gmail.com
Thu Sep 20 12:09:59 UTC 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1537404357 14400
#      Wed Sep 19 20:45:57 2018 -0400
# Node ID 4d2a7291137d1fc1ac8ac32862a1d3593f3eb10e
# Parent  6a29fe518906d0f21b7bdd76323d2f71e7667241
run-tests: quote PYTHON when spawning a subprocess

Same reason as 5abc47d4ca6b.  This covers running *.py tests, as well as inline
python blocks.  I didn't hit the path around line 3079, but it seems correct to
quote.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1213,7 +1213,8 @@ class PythonTest(Test):
 
     def _run(self, env):
         py3kswitch = self._py3kwarnings and b' -3' or b''
-        cmd = b'%s%s "%s"' % (PYTHON, py3kswitch, self.path)
+
+        cmd = b'"%s" %s "%s"' % (PYTHON, py3kswitch, self.path)
         vlog("# Running", cmd)
         normalizenewlines = os.name == 'nt'
         result = self._runcommand(cmd, env,
@@ -1475,7 +1476,7 @@ class TTest(Test):
                     # We've just entered a Python block. Add the header.
                     inpython = True
                     addsalt(prepos, False) # Make sure we report the exit code.
-                    script.append(b'%s -m heredoctest <<EOF\n' % PYTHON)
+                    script.append(b'"%s" -m heredoctest <<EOF\n' % PYTHON)
                 addsalt(n, True)
                 script.append(l[2:])
             elif l.startswith(b'  ... '): # python inlines
@@ -3078,7 +3079,7 @@ class TestRunner(object):
         if self._hgpath is not None:
             return self._hgpath
 
-        cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"'
+        cmd = b'"%s" -c "import mercurial; print (mercurial.__path__[0])"'
         cmd = cmd % PYTHON
         if PYTHON3:
             cmd = _strpath(cmd)


More information about the Mercurial-devel mailing list