[PATCH 10/10] tests: bsd sed doesn't allow replacing '\n'

Mike Kelly pioto at pioto.org
Fri May 25 06:43:31 PDT 2012


Various workarounds still don't act quite the same way. So, just use
perl, which seems to act the way these tests expect.
---
 test/maildir-sync |    2 +-
 test/multipart    |   22 +++++++++++-----------
 test/test-lib.sh  |    2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/test/maildir-sync b/test/maildir-sync
index d72ec07..311ea44 100755
--- a/test/maildir-sync
+++ b/test/maildir-sync
@@ -8,7 +8,7 @@ test_description="maildir synchronization"
 # --format=json" output includes some newlines. Also, need to avoid
 # including the local value of MAIL_DIR in the result.
 filter_show_json() {
-    sed -e 's/, /,\n/g'  | sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
+    perl -npe 's/, /,\n/g' | sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
     echo
 }
 
diff --git a/test/multipart b/test/multipart
index 72d3927..c868b7b 100755
--- a/test/multipart
+++ b/test/multipart
@@ -319,7 +319,7 @@ test_expect_success \
     "notmuch show --format=text --part=8 'id:87liy5ap00.fsf at yoom.home.cworth.org'"
 
 test_begin_subtest "--format=json --part=0, full message"
-notmuch show --format=json --part=0 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=0 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -337,7 +337,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=1, message body"
-notmuch show --format=json --part=1 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=1 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -354,7 +354,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=2, multipart/mixed"
-notmuch show --format=json --part=2 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=2 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -369,7 +369,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=3, rfc822 part"
-notmuch show --format=json --part=3 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=3 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -381,7 +381,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"
-notmuch show --format=json --part=4 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=4 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -392,7 +392,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=5, rfc822's html part"
-notmuch show --format=json --part=5 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=5 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -401,7 +401,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=6, rfc822's text part"
-notmuch show --format=json --part=6 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=6 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -410,7 +410,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=7, inline attachment"
-notmuch show --format=json --part=7 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=7 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -419,7 +419,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=8, plain text part"
-notmuch show --format=json --part=8 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=8 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -428,7 +428,7 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
-notmuch show --format=json --part=9 'id:87liy5ap00.fsf at yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
+notmuch show --format=json --part=9 'id:87liy5ap00.fsf at yoom.home.cworth.org' | perl -npe 's|{"id":|\n{"id":|g' >OUTPUT
 echo >>OUTPUT # expect *no* newline at end of output
 cat <<EOF >EXPECTED
 
@@ -669,4 +669,4 @@ notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
 echo -n -e "\xEF\x0D\x0A" > crlf.expected
 test_expect_equal_file crlf.out crlf.expected
 
-test_done
\ No newline at end of file
+test_done
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 06aaea2..4990ad6 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -565,7 +565,7 @@ notmuch_show_sanitize_all ()
 
 notmuch_json_show_sanitize ()
 {
-    sed -e 's|, |,\n |g' | \
+    perl -npe 's|, |,\n |g' | \
 	sed \
 	-e 's|"id": "[^"]*",|"id": "XXXXX",|' \
 	-e 's|"filename": "[^"]*",|"filename": "YYYYY",|'
-- 
1.7.10.2



More information about the notmuch mailing list