tests: fix portability of sed usage in test-mq stable
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sun, 01 Apr 2012 18:18:48 +0900
branchstable
changeset 16331 900767dfa80d
parent 16327 7c76587fb372
child 16334 b9bd95e61b49
tests: fix portability of sed usage in test-mq on some platform (Mac OS X and Solaris, at least), to insert new text line, sed function 'i' should be followed by: - backslash('\'), - new-line, - text to be inserted and - new-line GNU sed on Linux can recognize both previous and new ones as same modification request. in addition to it, this patch avoids to use '-i' option for sed, because it is not so portable, as noted in WritingTests wiki page.
tests/test-mq.t
--- a/tests/test-mq.t	Sat Mar 31 13:46:46 2012 -0500
+++ b/tests/test-mq.t	Sun Apr 01 18:18:48 2012 +0900
@@ -519,7 +519,10 @@
   $ hg qpush --move test.patch # already applied
   abort: cannot push to a previous patch: test.patch
   [255]
-  $ sed -i.bak '2i\# make qtip index different in series and fullseries' `hg root`/.hg/patches/series
+  $ sed '2i\
+  > # make qtip index different in series and fullseries
+  > ' `hg root`/.hg/patches/series > $TESTTMP/sedtmp
+  $ cp $TESTTMP/sedtmp `hg root`/.hg/patches/series
   $ cat `hg root`/.hg/patches/series
   # comment
   # make qtip index different in series and fullseries
@@ -1496,12 +1499,14 @@
 
 (restore env for next test)
 
-  $ sed -i.bak -e 's/new-commit=secret//' $HGRCPATH
+  $ sed -e 's/new-commit=secret//' $HGRCPATH > $TESTTMP/sedtmp
+  $ cp $TESTTMP/sedtmp $HGRCPATH
   $ hg qimport -r 1 --name  add-file2
 
 Test that qfinish preserve phase when mq.secret=false
 
-  $ sed -i.bak -e 's/secret=true/secret=false/' $HGRCPATH
+  $ sed -e 's/secret=true/secret=false/' $HGRCPATH > $TESTTMP/sedtmp
+  $ cp $TESTTMP/sedtmp $HGRCPATH
   $ hg qfinish qbase
   patch add-file2 finalized without changeset message
   $ hg phase 'all()'