Patchwork D12480: run-tests: introduce "forward-slash" version of everything on windows

login
register
mail settings
Submitter phabricator
Date April 6, 2022, 5:22 p.m.
Message ID <differential-rev-PHID-DREV-wxvsdewbjcjhff45dlgl-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50826/
State New
Headers show

Comments

phabricator - April 6, 2022, 5:22 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This should be useful for some shell invocation.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  tests/run-tests.py
  tests/test-racy-mutations.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-racy-mutations.t b/tests/test-racy-mutations.t
--- a/tests/test-racy-mutations.t
+++ b/tests/test-racy-mutations.t
@@ -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)
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -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,8 @@ 
             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 +3262,7 @@ 
         fileb = _sys2bytes(__file__)
         runtestdir = os.path.abspath(os.path.dirname(fileb))
         osenvironb[b'RUNTESTDIR'] = runtestdir
+        osenvironb[b'RUNTESTDIR_FORWARD_SLASH'] = osenvironb[b'RUNTESTDIR'].replace(os.sep.encode('ascii'), b'/')
         if PYTHON3:
             sepb = _sys2bytes(os.pathsep)
         else: