run-tests: also catch double-escapes for $TESTTMP
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 23 Jun 2021 14:34:55 +0200
changeset 47571 e9c5c368be17
parent 47570 bc01b8ad6134
child 47572 da497189a93a
run-tests: also catch double-escapes for $TESTTMP On Windows the `$TESTTMP` string "repr" is different than its value, because `\` become `\\`. We introduce a new `$STR_REPR_TESTTMP` substitution to match that too. Differential Revision: https://phab.mercurial-scm.org/D11001
tests/run-tests.py
tests/test-paths.t
--- a/tests/run-tests.py	Thu Jul 08 17:13:18 2021 +0200
+++ b/tests/run-tests.py	Wed Jun 23 14:34:55 2021 +0200
@@ -1308,6 +1308,11 @@
             (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.
+            replaced = self._testtmp.replace(b'\\', br'\\')
+            r.append((self._escapepath(replaced), b'$STR_REPR_TESTTMP'))
 
         replacementfile = os.path.join(self._testdir, b'common-pattern.py')
 
--- a/tests/test-paths.t	Thu Jul 08 17:13:18 2021 +0200
+++ b/tests/test-paths.t	Wed Jun 23 14:34:55 2021 +0200
@@ -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": "$STR_REPR_TESTTMP\\b#tip"}]
+  [{"url": "$STR_REPR_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)