D11001: run-tests: also catch double-escapes for $TESTTMP

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Wed Jul 7 13:15:22 UTC 2021


Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/run-tests.py
  tests/test-paths.t

CHANGE DETAILS

diff --git a/tests/test-paths.t b/tests/test-paths.t
--- a/tests/test-paths.t
+++ b/tests/test-paths.t
@@ -98,9 +98,15 @@
   expand: $TESTTMP/a/$SOMETHING/bar
   $ hg log -rnull -T '{get(peerurls, "dupe")}\n'
   $TESTTMP/b#tip
+#if windows
+  $ hg log -rnull -T '{peerurls % "{urls|json}\n"}'
+  [{"pushurl": "https://example.com/dupe", "url": "$TESTTMP\\b#tip"}]
+  [{"url": "$TESTTMP\\a\\$SOMETHING\\bar"}]
+#else
   $ hg log -rnull -T '{peerurls % "{urls|json}\n"}'
   [{"pushurl": "https://example.com/dupe", "url": "$TESTTMP/b#tip"}]
   [{"url": "$TESTTMP/a/$SOMETHING/bar"}]
+#endif
 
  (sub options can be populated by map/dot operation)
 
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1308,6 +1308,12 @@
             (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'),
         ]
         r.append((self._escapepath(self._testtmp), b'$TESTTMP'))
+        if os.name == 'nt':
+            # JSON output escapes backslashes in Windows paths, so also catch a
+            # double-escape.
+            r.append(
+                (self._escapepath(self._testtmp.replace(b'\\', br'\\')), b'$TESTTMP')
+            )
 
         replacementfile = os.path.join(self._testdir, b'common-pattern.py')
 



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


More information about the Mercurial-devel mailing list