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

login
register
mail settings
Submitter Matt Harbison
Date Sept. 20, 2018, 12:09 p.m.
Message ID <4d2a7291137d1fc1ac8a.1537445399@Envy>
Download mbox | patch
Permalink /patch/34842/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 20, 2018, 12:09 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@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.
Yuya Nishihara - Sept. 20, 2018, 12:37 p.m.
On Thu, 20 Sep 2018 08:09:59 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@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

Queued, thanks.

>          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)
                       ^
Removed extra ' ' in flight.

Patch

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)