[PATCH 2/2] test: fix order and format of test_expect_equal_file arguments
Dmitry Kurochkin
dmitry.kurochkin at gmail.com
Wed Feb 1 16:04:10 PST 2012
The patch fixes tests which were broken by the new
test_expect_equal_file() argument check. Some tests have correct
filename format, but wrong argument order. Others require files to be
renamed.
---
test/crypto | 10 +++++-----
test/dump-restore | 10 +++++-----
test/hooks | 8 ++++----
test/multipart | 20 ++++++++++----------
test/search-limiting | 22 +++++++++++-----------
test/symbol-hiding | 4 ++--
6 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/test/crypto b/test/crypto
index 446a58b..9fdf710 100755
--- a/test/crypto
+++ b/test/crypto
@@ -140,14 +140,14 @@ test_expect_equal \
mv "${GNUPGHOME}"{.bak,}
# create a test encrypted message with attachment
-cat <<EOF >TESTATTACHMENT
+cat <<EOF >TESTATTACHMENT.expected
This is a test file.
EOF
test_expect_success 'emacs delivery of encrypted message with attachment' \
'emacs_deliver_message \
"test encrypted message 001" \
"This is a test encrypted message.\n" \
- "(mml-attach-file \"TESTATTACHMENT\") (mml-secure-message-encrypt)"'
+ "(mml-attach-file \"TESTATTACHMENT.expected\") (mml-secure-message-encrypt)"'
test_begin_subtest "decryption, --format=text"
output=$(notmuch show --format=text --decrypt subject:"test encrypted message 001" \
@@ -170,7 +170,7 @@ Non-text part: application/pgp-encrypted
part{ ID: 4, Content-type: text/plain
This is a test encrypted message.
part}
-attachment{ ID: 5, Filename: TESTATTACHMENT, Content-type: application/octet-stream
+attachment{ ID: 5, Filename: TESTATTACHMENT.expected, Content-type: application/octet-stream
Non-text part: application/octet-stream
attachment}
part}
@@ -210,7 +210,7 @@ expected='[[[{"id": "XXXXX",
"content": "This is a test encrypted message.\n"},
{"id": 5,
"content-type": "application/octet-stream",
- "filename": "TESTATTACHMENT"}]}]}]},
+ "filename": "TESTATTACHMENT.expected"}]}]}]},
[]]]]'
test_expect_equal \
"$output" \
@@ -233,7 +233,7 @@ notmuch show \
--part=5 \
--decrypt \
subject:"test encrypted message 001" >OUTPUT
-test_expect_equal_file OUTPUT TESTATTACHMENT
+test_expect_equal_file OUTPUT TESTATTACHMENT.expected
test_begin_subtest "decryption failure with missing key"
mv "${GNUPGHOME}"{,.bak}
diff --git a/test/dump-restore b/test/dump-restore
index 439e998..a6cfce2 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -55,7 +55,7 @@ test_expect_success 'Invalid restore invocation' \
test_begin_subtest "dump outfile"
notmuch dump dump-outfile.actual
-test_expect_equal_file dump.expected dump-outfile.actual
+test_expect_equal_file dump-outfile.actual dump.expected
test_begin_subtest "dump outfile # deprecated"
test_expect_equal "Warning: the output file argument of dump is deprecated."\
@@ -63,7 +63,7 @@ test_expect_equal "Warning: the output file argument of dump is deprecated."\
test_begin_subtest "dump outfile --"
notmuch dump dump-1-arg-dash.actual --
-test_expect_equal_file dump.expected dump-1-arg-dash.actual
+test_expect_equal_file dump-1-arg-dash.actual dump.expected
# Note, we assume all messages from cworth have a message-id
# containing cworth.org
@@ -72,14 +72,14 @@ grep 'cworth[.]org' dump.expected > dump-cworth.expected
test_begin_subtest "dump -- from:cworth"
notmuch dump -- from:cworth > dump-dash-cworth.actual
-test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
+test_expect_equal_file dump-dash-cworth.actual dump-cworth.expected
test_begin_subtest "dump outfile from:cworth"
notmuch dump dump-outfile-cworth.actual from:cworth
-test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
+test_expect_equal_file dump-outfile-cworth.actual dump-cworth.expected
test_begin_subtest "dump outfile -- from:cworth"
notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
-test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
+test_expect_equal_file dump-outfile-dash-inbox.actual dump-cworth.expected
test_done
diff --git a/test/hooks b/test/hooks
index 77e8569..d084d1f 100755
--- a/test/hooks
+++ b/test/hooks
@@ -36,14 +36,14 @@ rm_hooks
generate_message
create_echo_hook "pre-new" expected output
notmuch new > /dev/null
-test_expect_equal_file expected output
+test_expect_equal_file output expected
test_begin_subtest "post-new is run"
rm_hooks
generate_message
create_echo_hook "post-new" expected output
notmuch new > /dev/null
-test_expect_equal_file expected output
+test_expect_equal_file output expected
test_begin_subtest "pre-new is run before post-new"
rm_hooks
@@ -51,7 +51,7 @@ generate_message
create_echo_hook "pre-new" pre-new.expected pre-new.output
create_echo_hook "post-new" post-new.expected post-new.output
notmuch new > /dev/null
-test_expect_equal_file post-new.expected post-new.output
+test_expect_equal_file post-new.output post-new.expected
test_begin_subtest "pre-new non-zero exit status (hook status)"
rm_hooks
@@ -77,7 +77,7 @@ NOTMUCH_NEW 2>output.stderr >output
cat output.stderr >> output
echo "Added 1 new message to the database." > expected
echo "Error: post-new hook failed with status 13" >> expected
-test_expect_equal_file expected output
+test_expect_equal_file output expected
# depends on the previous subtest leaving broken hook behind
test_expect_code 1 "post-new non-zero exit status (notmuch status)" "notmuch new"
diff --git a/test/multipart b/test/multipart
index 2dd73f5..c25cdf6 100755
--- a/test/multipart
+++ b/test/multipart
@@ -2,7 +2,7 @@
test_description="output of multipart message"
. ./test-lib.sh
-cat <<EOF > embedded_message
+cat <<EOF > embedded_message.expected
From: Carl Worth <cworth at cworth.org>
To: cworth at cworth.org
Subject: html message
@@ -25,7 +25,7 @@ This is an embedded message, with a multipart/alternative part.
--==-=-==--
EOF
-cat <<EOF > ${MAIL_DIR}/multipart
+cat <<EOF > ${MAIL_DIR}/multipart.expected
From: Carl Worth <cworth at cworth.org>
To: cworth at cworth.org
Subject: Multipart message
@@ -44,8 +44,8 @@ Content-Type: message/rfc822
Content-Disposition: inline
EOF
-cat embedded_message >> ${MAIL_DIR}/multipart
-cat <<EOF >> ${MAIL_DIR}/multipart
+cat embedded_message.expected >> ${MAIL_DIR}/multipart.expected
+cat <<EOF >> ${MAIL_DIR}/multipart.expected
--=-=-=
Content-Disposition: attachment; filename=attachment
@@ -108,7 +108,7 @@ notmuch new > /dev/null
test_begin_subtest "--format=text --part=0, full message"
notmuch show --format=text --part=0 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
cat <<EOF >EXPECTED
-message{ id:87liy5ap00.fsf at yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart
+message{ id:87liy5ap00.fsf at yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart.expected
header{
Carl Worth <cworth at cworth.org> (2001-01-05) (attachment inbox signed unread)
Subject: Multipart message
@@ -322,7 +322,7 @@ notmuch show --format=json --part=0 'id:87liy5ap00.fsf at yoom.home.cworth.org' | s
echo >>OUTPUT # expect *no* newline at end of output
cat <<EOF >EXPECTED
-{"id": "87liy5ap00.fsf at yoom.home.cworth.org", "match": true, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth at cworth.org>", "To": "cworth at cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
+{"id": "87liy5ap00.fsf at yoom.home.cworth.org", "match": true, "filename": "${MAIL_DIR}/multipart.expected", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth at cworth.org>", "To": "cworth at cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
{"id": 1, "content-type": "multipart/signed", "content": [
{"id": 2, "content-type": "multipart/mixed", "content": [
{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth at cworth.org>", "To": "cworth at cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
@@ -441,11 +441,11 @@ test_expect_success \
test_begin_subtest "--format=raw"
notmuch show --format=raw 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
-test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
+test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart.expected
test_begin_subtest "--format=raw --part=0, full message"
notmuch show --format=raw --part=0 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
-test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
+test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart.expected
test_begin_subtest "--format=raw --part=1, message body"
notmuch show --format=raw --part=1 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
@@ -494,7 +494,7 @@ test_begin_subtest "--format=raw --part=3, rfc822 part"
test_subtest_known_broken
notmuch show --format=raw --part=3 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
-test_expect_equal_file OUTPUT embedded_message
+test_expect_equal_file OUTPUT embedded_message.expected
test_begin_subtest "--format=raw --part=4, rfc822's html part"
notmuch show --format=raw --part=4 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
@@ -556,7 +556,7 @@ test_expect_success \
test_begin_subtest "--format=mbox"
notmuch show --format=mbox 'id:87liy5ap00.fsf at yoom.home.cworth.org' >OUTPUT
printf "From cworth at cworth.org Fri Jan 5 15:43:57 2001\n" >EXPECTED
-cat "${MAIL_DIR}"/multipart >>EXPECTED
+cat "${MAIL_DIR}"/multipart.expected >>EXPECTED
# mbox output is expected to include a blank line
echo >>EXPECTED
test_expect_equal_file OUTPUT EXPECTED
diff --git a/test/search-limiting b/test/search-limiting
index 303762c..e93c76a 100755
--- a/test/search-limiting
+++ b/test/search-limiting
@@ -8,19 +8,19 @@ for outp in messages threads; do
test_begin_subtest "${outp}: limit does the right thing"
notmuch search --output=${outp} "*" | head -n 20 >expected
notmuch search --output=${outp} --limit=20 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: concatenation of limited searches"
notmuch search --output=${outp} "*" | head -n 20 >expected
notmuch search --output=${outp} --limit=10 "*" >output
notmuch search --output=${outp} --limit=10 --offset=10 "*" >>output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: limit larger than result set"
N=`notmuch count --output=${outp} "*"`
notmuch search --output=${outp} "*" >expected
notmuch search --output=${outp} --limit=$((1 + ${N})) "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: limit = 0"
test_expect_equal "`notmuch search --output=${outp} --limit=0 "*"`" ""
@@ -29,43 +29,43 @@ for outp in messages threads; do
# note: tail -n +N is 1-based
notmuch search --output=${outp} "*" | tail -n +21 >expected
notmuch search --output=${outp} --offset=20 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: offset = 0"
notmuch search --output=${outp} "*" >expected
notmuch search --output=${outp} --offset=0 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: negative offset"
notmuch search --output=${outp} "*" | tail -n 20 >expected
notmuch search --output=${outp} --offset=-20 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: negative offset"
notmuch search --output=${outp} "*" | tail -n 1 >expected
notmuch search --output=${outp} --offset=-1 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: negative offset combined with limit"
notmuch search --output=${outp} "*" | tail -n 20 | head -n 10 >expected
notmuch search --output=${outp} --offset=-20 --limit=10 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: negative offset combined with equal limit"
notmuch search --output=${outp} "*" | tail -n 20 >expected
notmuch search --output=${outp} --offset=-20 --limit=20 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: negative offset combined with large limit"
notmuch search --output=${outp} "*" | tail -n 20 >expected
notmuch search --output=${outp} --offset=-20 --limit=50 "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
test_begin_subtest "${outp}: negative offset larger then results"
N=`notmuch count --output=${outp} "*"`
notmuch search --output=${outp} "*" >expected
notmuch search --output=${outp} --offset=-$((1 + ${N})) "*" >output
- test_expect_equal_file expected output
+ test_expect_equal_file output expected
done
test_done
diff --git a/test/symbol-hiding b/test/symbol-hiding
index 636ec91..e6d896c 100755
--- a/test/symbol-hiding
+++ b/test/symbol-hiding
@@ -27,7 +27,7 @@ test_expect_equal "$result" "$output"
test_begin_subtest 'comparing existing to exported symbols'
objdump -t $TEST_DIRECTORY/../lib/*.o | awk '$4 == ".text" && $6 ~ "^notmuch" {print $6}' | sort | uniq > ACTUAL
-sed -n 's/[[:blank:]]*\(notmuch_[^;]*\);/\1/p' $TEST_DIRECTORY/../notmuch.sym | sort | uniq > EXPORTED
-test_expect_equal_file EXPORTED ACTUAL
+sed -n 's/[[:blank:]]*\(notmuch_[^;]*\);/\1/p' $TEST_DIRECTORY/../notmuch.sym | sort | uniq > EXPECTED
+test_expect_equal_file ACTUAL EXPECTED
test_done
--
1.7.9
More information about the notmuch
mailing list