Patchwork D10633: tests: ensure `$PYTHON` is quoted for Windows

login
register
mail settings
Submitter phabricator
Date May 3, 2021, 6:23 p.m.
Message ID <differential-rev-PHID-DREV-vnj2qum3f7zy35ghopnx-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48956/
State Superseded
Headers show

Comments

phabricator - May 3, 2021, 6:23 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Global installs of python3 go into "Program Files", and tons of tests fail with
  mysterious errors if this isn't quoted.  Most of this is a followup to
  0826d684a1b5 <https://phab.mercurial-scm.org/rHG0826d684a1b596f8768e049b0ae4c04007d292a0>, but a some of these were existing issues.  Shebang lines are
  ignored because quoting breaks direct execution- these will need to be launched
  indirectly with the quoted `$PYTHON` command.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D10633

AFFECTED FILES
  tests/library-infinitepush.sh
  tests/narrow-library.sh
  tests/remotefilelog-library.sh
  tests/test-check-pyflakes.t
  tests/test-convert-svn-encoding.t
  tests/test-fuzz-targets.t
  tests/test-infinitepush-ci.t
  tests/test-nointerrupt.t
  tests/test-remotefilelog-cacheprocess.t
  tests/test-remotefilelog-gc.t
  tests/test-remotefilelog-http.t
  tests/test-unified-test.t
  tests/test-update-atomic.t
  tests/test-verify-repo-operations.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-verify-repo-operations.py b/tests/test-verify-repo-operations.py
--- a/tests/test-verify-repo-operations.py
+++ b/tests/test-verify-repo-operations.py
@@ -354,7 +354,7 @@ 
             o.write(content)
         self.log.append(
             (
-                "$ $PYTHON -c 'import binascii; "
+                "$ \"$PYTHON\" -c 'import binascii; "
                 "print(binascii.unhexlify(\"%s\"))' > %s"
             )
             % (
diff --git a/tests/test-update-atomic.t b/tests/test-update-atomic.t
--- a/tests/test-update-atomic.t
+++ b/tests/test-update-atomic.t
@@ -54,7 +54,7 @@ 
   $ hg update -r 1 --config extensions.showwrites=.hg/showwrites.py 2>&1 | grep "a1'.*wb"
   ('vfs open', ('a1', 'wb'), [('atomictemp', False), ('backgroundclose', True)])
 
-  $ $PYTHON $TESTTMP/show_mode.py *
+  $ "$PYTHON" $TESTTMP/show_mode.py *
   a1:0644
   a2:0755
   b1:0644
@@ -76,7 +76,7 @@ 
   $ hg update -r 1
   6 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
-  $ $PYTHON $TESTTMP/show_mode.py *
+  $ "$PYTHON" $TESTTMP/show_mode.py *
   a1:0644
   a2:0755
   b1:0644
@@ -88,7 +88,7 @@ 
 
   $ chmod a-w ro
 
-  $ $PYTHON $TESTTMP/show_mode.py ro
+  $ "$PYTHON" $TESTTMP/show_mode.py ro
   ro:0444
 
 Now the file is present, try to update and check the permissions of the file
@@ -96,7 +96,7 @@ 
   $ hg up -r 2
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-  $ $PYTHON $TESTTMP/show_mode.py ro
+  $ "$PYTHON" $TESTTMP/show_mode.py ro
   ro:0644
 
 # The file which was read-only is now writable in the default behavior
@@ -121,7 +121,7 @@ 
   C ro
 
 Check the file permission after update
-  $ $PYTHON $TESTTMP/show_mode.py *
+  $ "$PYTHON" $TESTTMP/show_mode.py *
   a1:0644
   a2:0755
   b1:0644
@@ -133,7 +133,7 @@ 
 
   $ chmod a-w ro
 
-  $ $PYTHON $TESTTMP/show_mode.py ro
+  $ "$PYTHON" $TESTTMP/show_mode.py ro
   ro:0444
 
 Now the file is present, try to update and check the permissions of the file
@@ -141,7 +141,7 @@ 
   $ hg update -r 2 --traceback
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-  $ $PYTHON $TESTTMP/show_mode.py ro
+  $ "$PYTHON" $TESTTMP/show_mode.py ro
   ro:0644
 
 # The behavior is the same as without atomic update
diff --git a/tests/test-unified-test.t b/tests/test-unified-test.t
--- a/tests/test-unified-test.t
+++ b/tests/test-unified-test.t
@@ -77,12 +77,12 @@ 
 
 Escapes:
 
-  $ $PYTHON -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")'
+  $ "$PYTHON" -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")'
   \xff (no-eol) (esc)
 
 Escapes with conditions:
 
-  $ $PYTHON -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")'
+  $ "$PYTHON" -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")'
   \xff (no-eol) (esc) (true !)
 
 Combining esc with other markups - and handling lines ending with \r instead of \n:
diff --git a/tests/test-remotefilelog-http.t b/tests/test-remotefilelog-http.t
--- a/tests/test-remotefilelog-http.t
+++ b/tests/test-remotefilelog-http.t
@@ -14,7 +14,7 @@ 
   $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log -A ../access.log
 
 Build a query string for later use:
-  $ GET=`hg debugdata -m 0 | $PYTHON -c \
+  $ GET=`hg debugdata -m 0 | "$PYTHON" -c \
   > 'import sys ; print([("?cmd=x_rfl_getfile&file=%s&node=%s" % tuple(s.split("\0"))) for s in sys.stdin.read().splitlines()][0])'`
 
   $ cd ..
diff --git a/tests/test-remotefilelog-gc.t b/tests/test-remotefilelog-gc.t
--- a/tests/test-remotefilelog-gc.t
+++ b/tests/test-remotefilelog-gc.t
@@ -40,7 +40,7 @@ 
 
 # gc client cache
 
-  $ lastweek=`$PYTHON -c 'import datetime,time; print(datetime.datetime.fromtimestamp(time.time() - (86400 * 7)).strftime("%y%m%d%H%M"))'`
+  $ lastweek=`"$PYTHON" -c 'import datetime,time; print(datetime.datetime.fromtimestamp(time.time() - (86400 * 7)).strftime("%y%m%d%H%M"))'`
   $ find $CACHEDIR -type f -exec touch -t $lastweek {} \;
 
   $ find $CACHEDIR -type f | sort
diff --git a/tests/test-remotefilelog-cacheprocess.t b/tests/test-remotefilelog-cacheprocess.t
--- a/tests/test-remotefilelog-cacheprocess.t
+++ b/tests/test-remotefilelog-cacheprocess.t
@@ -66,7 +66,7 @@ 
 
   $ cat >> $HGRCPATH <<EOF
   > [remotefilelog]
-  > cacheprocess = $PYTHON $TESTTMP/cacheprocess-logger.py
+  > cacheprocess = "$PYTHON" $TESTTMP/cacheprocess-logger.py
   > EOF
 
 Test cache keys and cache misses.
diff --git a/tests/test-nointerrupt.t b/tests/test-nointerrupt.t
--- a/tests/test-nointerrupt.t
+++ b/tests/test-nointerrupt.t
@@ -59,7 +59,7 @@ 
   > EOF
 
 Test ctrl-c
-  $ $PYTHON $TESTTMP/timeout.py -s INT 1 hg sleep 2
+  $ "$PYTHON" $TESTTMP/timeout.py -s INT 1 hg sleep 2
   interrupted!
   [124]
 
@@ -68,7 +68,7 @@ 
   > nointerrupt = yes
   > EOF
 
-  $ $PYTHON $TESTTMP/timeout.py -s INT 1 hg sleep 2
+  $ "$PYTHON" $TESTTMP/timeout.py -s INT 1 hg sleep 2
   interrupted!
   [124]
 
@@ -77,7 +77,7 @@ 
   > nointerrupt-interactiveonly = False
   > EOF
 
-  $ $PYTHON $TESTTMP/timeout.py -s INT 1 hg sleep 2
+  $ "$PYTHON" $TESTTMP/timeout.py -s INT 1 hg sleep 2
   shutting down cleanly
   press ^C again to terminate immediately (dangerous)
   end of unsafe operation
diff --git a/tests/test-infinitepush-ci.t b/tests/test-infinitepush-ci.t
--- a/tests/test-infinitepush-ci.t
+++ b/tests/test-infinitepush-ci.t
@@ -10,7 +10,7 @@ 
   $ . "$TESTDIR/library-infinitepush.sh"
   $ cat >> $HGRCPATH <<EOF
   > [ui]
-  > ssh = $PYTHON "$TESTDIR/dummyssh"
+  > ssh = "$PYTHON" "$TESTDIR/dummyssh"
   > [alias]
   > glog = log -GT "{rev}:{node|short} {desc}\n{phase}"
   > EOF
diff --git a/tests/test-fuzz-targets.t b/tests/test-fuzz-targets.t
--- a/tests/test-fuzz-targets.t
+++ b/tests/test-fuzz-targets.t
@@ -29,7 +29,7 @@ 
 Try to find a python3-config that's next to our sys.executable. If
 that doesn't work, fall back to looking for a global python3-config
 and hope that works out for the best.
-  $ PYBIN=`$PYTHON -c 'import sys, os; print(os.path.dirname(sys.executable))'`
+  $ PYBIN=`"$PYTHON" -c 'import sys, os; print(os.path.dirname(sys.executable))'`
   $ if [ -x "$PYBIN/python3-config" ] ; then
   >   PYTHON_CONFIG="$PYBIN/python3-config"
   > else
diff --git a/tests/test-convert-svn-encoding.t b/tests/test-convert-svn-encoding.t
--- a/tests/test-convert-svn-encoding.t
+++ b/tests/test-convert-svn-encoding.t
@@ -155,7 +155,7 @@ 
 
 Subversion sources don't support non-ASCII characters in HTTP(S) URLs.
 
-  $ XFF=$($PYTHON -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")')
+  $ XFF=$("$PYTHON" -c 'from mercurial.utils.procutil import stdout; stdout.write(b"\xff")')
   $ hg convert --source-type=svn http://localhost:$HGPORT/$XFF test
   initializing destination test repository
   Subversion sources don't support non-ASCII characters in HTTP(S) URLs. Please percent-encode them.
diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t
--- a/tests/test-check-pyflakes.t
+++ b/tests/test-check-pyflakes.t
@@ -8,7 +8,7 @@ 
   $ cat > test.py <<EOF
   > print(undefinedname)
   > EOF
-  $ $PYTHON -m pyflakes test.py 2>/dev/null | "$TESTDIR/filterpyflakes.py"
+  $ "$PYTHON" -m pyflakes test.py 2>/dev/null | "$TESTDIR/filterpyflakes.py"
   test.py:1:* undefined name 'undefinedname' (glob)
   
   $ cd "`dirname "$TESTDIR"`"
@@ -18,7 +18,7 @@ 
   > -X mercurial/pycompat.py -X contrib/python-zstandard \
   > -X mercurial/thirdparty \
   > 2>/dev/null \
-  > | xargs $PYTHON -m pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
+  > | xargs "$PYTHON" -m pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
   contrib/perf.py:*:* undefined name 'xrange' (glob) (?)
   mercurial/hgweb/server.py:*:* undefined name 'reload' (glob) (?)
   mercurial/util.py:*:* undefined name 'file' (glob) (?)
diff --git a/tests/remotefilelog-library.sh b/tests/remotefilelog-library.sh
--- a/tests/remotefilelog-library.sh
+++ b/tests/remotefilelog-library.sh
@@ -8,7 +8,7 @@ 
 rebase=
 strip=
 [ui]
-ssh=$PYTHON "$TESTDIR/dummyssh"
+ssh="$PYTHON" "$TESTDIR/dummyssh"
 [server]
 preferuncompressed=True
 [experimental]
@@ -67,7 +67,7 @@ 
 }
 
 ls_l() {
-  $PYTHON $TESTDIR/ls-l.py "$@"
+  "$PYTHON" $TESTDIR/ls-l.py "$@"
 }
 
 identifyrflcaps() {
diff --git a/tests/narrow-library.sh b/tests/narrow-library.sh
--- a/tests/narrow-library.sh
+++ b/tests/narrow-library.sh
@@ -2,7 +2,7 @@ 
 [extensions]
 narrow=
 [ui]
-ssh=$PYTHON "$RUNTESTDIR/dummyssh"
+ssh="$PYTHON" "$RUNTESTDIR/dummyssh"
 [experimental]
 changegroup3 = True
 EOF
diff --git a/tests/library-infinitepush.sh b/tests/library-infinitepush.sh
--- a/tests/library-infinitepush.sh
+++ b/tests/library-infinitepush.sh
@@ -15,7 +15,7 @@ 
 [extensions]
 infinitepush=
 [ui]
-ssh = $PYTHON "$TESTDIR/dummyssh"
+ssh = "$PYTHON" "$TESTDIR/dummyssh"
 [infinitepush]
 branchpattern=re:scratch/.*
 EOF