run-tests: introduce "forward-slash" version of everything on windows
This should be useful for some shell invocation.
Differential Revision: https://phab.mercurial-scm.org/D12480
--- a/tests/run-tests.py Wed Apr 06 18:44:21 2022 +0200
+++ b/tests/run-tests.py Wed Apr 06 18:50:20 2022 +0200
@@ -1433,6 +1433,9 @@
env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or ''
env['HGEMITWARNINGS'] = '1'
env['TESTTMP'] = _bytes2sys(self._testtmp)
+ # the FORWARD_SLASH version is useful when running `sh` on non unix
+ # system (e.g. Windows)
+ env['TESTTMP_FORWARD_SLASH'] = env['TESTTMP'].replace(os.sep, '/')
uid_file = os.path.join(_bytes2sys(self._testtmp), 'UID')
env['HGTEST_UUIDFILE'] = uid_file
env['TESTNAME'] = self.name
@@ -3113,6 +3116,10 @@
if pathname:
testdir = os.path.join(testdir, pathname)
self._testdir = osenvironb[b'TESTDIR'] = testdir
+ osenvironb[b'TESTDIR_FORWARD_SLASH'] = osenvironb[b'TESTDIR'].replace(
+ os.sep.encode('ascii'), b'/'
+ )
+
if self.options.outputdir:
self._outputdir = canonpath(_sys2bytes(self.options.outputdir))
else:
@@ -3257,6 +3264,9 @@
fileb = _sys2bytes(__file__)
runtestdir = os.path.abspath(os.path.dirname(fileb))
osenvironb[b'RUNTESTDIR'] = runtestdir
+ osenvironb[b'RUNTESTDIR_FORWARD_SLASH'] = runtestdir.replace(
+ os.sep.encode('ascii'), b'/'
+ )
if PYTHON3:
sepb = _sys2bytes(os.pathsep)
else:
--- a/tests/test-racy-mutations.t Wed Apr 06 18:44:21 2022 +0200
+++ b/tests/test-racy-mutations.t Wed Apr 06 18:50:20 2022 +0200
@@ -9,12 +9,12 @@
$ hg init a
$ cd a
- $ cat > "$TESTTMP/waitlock_editor.sh" <<EOF
+ $ cat > "$TESTTMP_FORWARD_SLASH/waitlock_editor.sh" <<EOF
> [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}"
> f="\${WAITLOCK_FILE}"
> start=\`date +%s\`
> timeout=5
- > $RUNTESTDIR/testlib/wait-on-file "\$timeout" "\$f"
+ > "$RUNTESTDIR_FORWARD_SLASH/testlib/wait-on-file" "\$timeout" "\$f"
> if [ \$# -gt 1 ]; then
> cat "\$@"
> fi
@@ -27,9 +27,9 @@
$ hg commit -qAm 'r0'
Start an hg commit that will take a while
- $ EDITOR_STARTED="$(pwd)/.editor_started"
- $ MISCHIEF_MANAGED="$(pwd)/.mischief_managed"
- $ JOBS_FINISHED="$(pwd)/.jobs_finished"
+ $ EDITOR_STARTED="$TESTTMP_FORWARD_SLASH/a/.editor_started"
+ $ MISCHIEF_MANAGED="$TESTTMP_FORWARD_SLASH/a/.mischief_managed"
+ $ JOBS_FINISHED="$TESTTMP_FORWARD_SLASH/a/.jobs_finished"
#if fail-if-detected
$ cat >> .hg/hgrc << EOF
@@ -40,7 +40,7 @@
$ cat >> .hg/hgrc << EOF
> [ui]
- > editor=sh $TESTTMP/waitlock_editor.sh
+ > editor=sh $TESTTMP_FORWARD_SLASH/waitlock_editor.sh
> EOF
$ echo foo > foo
@@ -50,7 +50,7 @@
> hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; touch "${JOBS_FINISHED}") &
Wait for the "editor" to actually start
- $ sh "$RUNTESTDIR/testlib/wait-on-file" 5 "${EDITOR_STARTED}"
+ $ sh "$RUNTESTDIR_FORWARD_SLASH/testlib/wait-on-file" 5 "${EDITOR_STARTED}"
$ cat >> .hg/hgrc << EOF
> [ui]
@@ -69,7 +69,7 @@
Awaken the editor from that first commit
$ touch "${MISCHIEF_MANAGED}"
And wait for it to finish
- $ WAITLOCK_FILE="${JOBS_FINISHED}" sh "$TESTTMP/waitlock_editor.sh"
+ $ WAITLOCK_FILE="${JOBS_FINISHED}" sh "$TESTTMP_FORWARD_SLASH/waitlock_editor.sh"
#if skip-detection
(Ensure there was no output)