Patchwork D1699: tests: avoid echo with backslash escapes

login
register
mail settings
Submitter phabricator
Date Dec. 15, 2017, 6:57 a.m.
Message ID <differential-rev-PHID-DREV-5rjhsmnhkf3gjb4ypbga-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26296/
State Superseded
Headers show

Comments

phabricator - Dec. 15, 2017, 6:57 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Some shells' echo (e.g. Bash's) do not interpret backslash escapes by
  default, while others shells' do (e.g. Dash's). This led to a failure
  in test-run-tests.t. We could switch to the more compatible printf,
  but using a heredoc seems simpler, so that's what this patch does.
  
  For anyone who wants to test this for themselves, remove the "unset
  HGTEST_SHELL" line in helper-runtests.sh and pass
  e.g. "--shell=/bin/dash" to the test runner.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-run-tests.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -703,12 +703,14 @@ 
 
 Accept the fix
 
-  $ echo "  $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
-  $ echo "  saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t
-  $ echo "  $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
-  $ echo "  saved backup bundle to \$TESTTMP\\foo.hg" >> test-failure.t
-  $ echo "  $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
-  $ echo "  saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t
+  $ cat >> test-failure.t <<EOF
+  >   $ echo 'saved backup bundle to \$TESTTMP/foo.hg'
+  >   saved backup bundle to \$TESTTMP/foo.hg
+  >   $ echo 'saved backup bundle to \$TESTTMP/foo.hg'
+  >   saved backup bundle to $TESTTMP\\foo.hg
+  >   $ echo 'saved backup bundle to \$TESTTMP/foo.hg'
+  >   saved backup bundle to \$TESTTMP/*.hg (glob)
+  > EOF
   $ echo 'y' | rt -i 2>&1
   
   --- $TESTTMP/test-failure.t