From patchwork Wed Jul 7 13:15:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11001: run-tests: also catch double-escapes for $TESTTMP From: phabricator X-Patchwork-Id: 49318 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 7 Jul 2021 13:15:22 +0000 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 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')