Patchwork [1,of,3,STABLE] run-tests: include quotes in the HGEDITOR value when storing sys.executable

login
register
mail settings
Submitter Matt Harbison
Date Nov. 17, 2014, 5:05 a.m.
Message ID <527b28eba0508dab4389.1416200743@Envy>
Download mbox | patch
Permalink /patch/6767/
State Accepted
Commit 49cdf51cbc6c42bb6785c1b3f64b7ed8258f79d3
Headers show

Comments

Matt Harbison - Nov. 17, 2014, 5:05 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1415123160 18000
#      Tue Nov 04 12:46:00 2014 -0500
# Branch stable
# Node ID 527b28eba0508dab438963f37607a85db0b743a6
# Parent  3246801ff3135322544f804c2b081f4da2e39646
run-tests: include quotes in the HGEDITOR value when storing sys.executable

This fixes test-install.t on Windows that broke in 2122b82b6987 when
shlex.split() was added to the debuginstall command:

    @@ -7,8 +7,11 @@
       checking installed modules (*mercurial)... (glob)
       checking templates (*mercurial?templates)... (glob)
       checking commit editor...
    +   Can't find editor 'c:\Python27\python.exe -c "(omitted)"' in PATH
    +   (specify a commit editor in your configuration file)
       checking username...
    -  no problems detected
    +  1 problems detected, please check your install!
    +  [1]

What happens is that shlex.split() on Windows turns this:

    c:\Python27\python.exe -c "import sys; sys.exit(0)"

into this:

    ['c:Python27python.exe', '-c', 'import sys; sys.exit(0)']

While technically a regression, most programs on Windows live in some flavor of
'Program Files', and therefore the environment variable needs to contain quotes
anyway to handle the space.  This wasn't handled prior to the shlex() change,
because it tested the whole environment variable to see if it was an executable,
or split on the first space and tested again.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -649,7 +649,8 @@ 
         env["HGPORT2"] = str(self._startport + 2)
         env["HGRCPATH"] = os.path.join(self._threadtmp, '.hgrc')
         env["DAEMON_PIDS"] = os.path.join(self._threadtmp, 'daemon.pids')
-        env["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
+        env["HGEDITOR"] = ('"' + sys.executable + '"'
+                           + ' -c "import sys; sys.exit(0)"')
         env["HGMERGE"] = "internal:merge"
         env["HGUSER"]   = "test"
         env["HGENCODING"] = "ascii"