tests: ensure `$PYTHON` is quoted for Windows
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, 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.
Differential Revision: https://phab.mercurial-scm.org/D10633
--- a/tests/library-infinitepush.sh Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/library-infinitepush.sh Sat May 01 00:41:43 2021 -0400
@@ -15,7 +15,7 @@
[extensions]
infinitepush=
[ui]
-ssh = $PYTHON "$TESTDIR/dummyssh"
+ssh = "$PYTHON" "$TESTDIR/dummyssh"
[infinitepush]
branchpattern=re:scratch/.*
EOF
--- a/tests/narrow-library.sh Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/narrow-library.sh Sat May 01 00:41:43 2021 -0400
@@ -2,7 +2,7 @@
[extensions]
narrow=
[ui]
-ssh=$PYTHON "$RUNTESTDIR/dummyssh"
+ssh="$PYTHON" "$RUNTESTDIR/dummyssh"
[experimental]
changegroup3 = True
EOF
--- a/tests/remotefilelog-library.sh Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/remotefilelog-library.sh Sat May 01 00:41:43 2021 -0400
@@ -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() {
--- a/tests/test-check-pyflakes.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-check-pyflakes.t Sat May 01 00:41:43 2021 -0400
@@ -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) (?)
--- a/tests/test-convert-svn-encoding.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-convert-svn-encoding.t Sat May 01 00:41:43 2021 -0400
@@ -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.
--- a/tests/test-fuzz-targets.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-fuzz-targets.t Sat May 01 00:41:43 2021 -0400
@@ -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
--- a/tests/test-infinitepush-ci.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-infinitepush-ci.t Sat May 01 00:41:43 2021 -0400
@@ -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
--- a/tests/test-nointerrupt.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-nointerrupt.t Sat May 01 00:41:43 2021 -0400
@@ -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
--- a/tests/test-remotefilelog-cacheprocess.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-remotefilelog-cacheprocess.t Sat May 01 00:41:43 2021 -0400
@@ -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.
--- a/tests/test-remotefilelog-gc.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-remotefilelog-gc.t Sat May 01 00:41:43 2021 -0400
@@ -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
--- a/tests/test-remotefilelog-http.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-remotefilelog-http.t Sat May 01 00:41:43 2021 -0400
@@ -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 ..
--- a/tests/test-unified-test.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-unified-test.t Sat May 01 00:41:43 2021 -0400
@@ -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:
--- a/tests/test-update-atomic.t Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-update-atomic.t Sat May 01 00:41:43 2021 -0400
@@ -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
--- a/tests/test-verify-repo-operations.py Fri Apr 30 16:13:02 2021 -0700
+++ b/tests/test-verify-repo-operations.py Sat May 01 00:41:43 2021 -0400
@@ -354,7 +354,7 @@
o.write(content)
self.log.append(
(
- "$ $PYTHON -c 'import binascii; "
+ "$ \"$PYTHON\" -c 'import binascii; "
"print(binascii.unhexlify(\"%s\"))' > %s"
)
% (