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

login
register
mail settings
Submitter phabricator
Date July 7, 2021, 1:15 p.m.
Message ID <differential-rev-PHID-DREV-vk6v2zhvupv6kblv6tyy-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49318/
State Superseded
Headers show

Comments

phabricator - July 7, 2021, 1:15 p.m.
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




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

Patch

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')