[PATCH v2 4/5] Adding tests for --format=sexp.
Austin Clements
aclements at csail.mit.edu
Tue Dec 4 11:24:54 PST 2012
It would be nice to use something like test_expect_equal_json for this
(probably based on Emacs' pp function), but this is fine for now.
On Tue, 04 Dec 2012, Peter Feigl <craven at gmx.net> wrote:
> Add basic tests, the same as for json, for the S-Expression output
> format.
> ---
> test/notmuch-test | 1 +
> test/sexp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
> create mode 100755 test/sexp
>
> diff --git a/test/notmuch-test b/test/notmuch-test
> index a6ef34f..ca9c3dc 100755
> --- a/test/notmuch-test
> +++ b/test/notmuch-test
> @@ -31,6 +31,7 @@ TESTS="
> excludes
> tagging
> json
> + sexp
> text
> multipart
> thread-naming
> diff --git a/test/sexp b/test/sexp
> new file mode 100755
> index 0000000..fdc9de6
> --- /dev/null
> +++ b/test/sexp
> @@ -0,0 +1,48 @@
> +#!/usr/bin/env bash
> +test_description="--format=sexp output"
> +. ./test-lib.sh
> +
> +test_begin_subtest "Show message: sexp"
> +add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc at notmuchmail.org\"" "[reply-to]=\"test_suite+replyto at notmuchmail.org\"" "[body]=\"sexp-show-message\""
> +output=$(notmuch show --format=sexp "sexp-show-message")
> +test_expect_equal "$output" "(((((id \"msg-001 at notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-001\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-subject\") (From \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (Bcc \"test_suite+bcc at notmuchmail.org\") (Reply-To \"test_suite+replyto at notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"text/plain\") (content \"sexp-show-message\n\"))))) ())))"
> +
> +# This should be the same output as above.
> +test_begin_subtest "Show message: sexp --body=true"
> +output=$(notmuch show --format=sexp --body=true "sexp-show-message")
> +test_expect_equal "$output" "(((((id \"msg-001 at notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-001\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-subject\") (From \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (Bcc \"test_suite+bcc at notmuchmail.org\") (Reply-To \"test_suite+replyto at notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"text/plain\") (content \"sexp-show-message\n\"))))) ())))"
> +
> +test_begin_subtest "Show message: sexp --body=false"
> +output=$(notmuch show --format=sexp --body=false "sexp-show-message")
> +test_expect_equal "$output" "(((((id \"msg-001 at notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-001\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-subject\") (From \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (Bcc \"test_suite+bcc at notmuchmail.org\") (Reply-To \"test_suite+replyto at notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\")))) ())))"
> +
> +test_begin_subtest "Search message: sexp"
> +add_message "[subject]=\"sexp-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"sexp-search-message\""
> +output=$(notmuch search --format=sexp "sexp-search-message" | notmuch_search_sanitize)
> +test_expect_equal "$output" "(((thread \"0000000000000002\") (timestamp 946728000) (date_relative \"2000-01-01\") (matched 1) (total 1) (authors \"Notmuch Test Suite\") (subject \"sexp-search-subject\") (tags (\"inbox\" \"unread\"))))"
> +
> +test_begin_subtest "Show message: sexp, utf-8"
> +add_message "[subject]=\"sexp-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\""
> +output=$(notmuch show --format=sexp "jsön-show-méssage")
> +test_expect_equal "$output" "(((((id \"msg-003 at notmuch-test-suite\") (match t) (excluded nil) (filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/msg-003\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\" \"unread\")) (headers ((Subject \"sexp-show-utf8-body-sübjéct\") (From \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (To \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"text/plain\") (content \"jsön-show-méssage\n\"))))) ())))"
> +
> +test_begin_subtest "Show message: sexp, inline attachment filename"
> +subject='sexp-show-inline-attachment-filename'
> +id="sexp-show-inline-attachment-filename at notmuchmail.org"
> +emacs_deliver_message \
> + "$subject" \
> + 'This is a test message with inline attachment with a filename' \
> + "(mml-attach-file \"$TEST_DIRECTORY/README\" nil nil \"inline\")
> + (message-goto-eoh)
> + (insert \"Message-ID: <$id>\n\")"
> +output=$(notmuch show --format=sexp "id:$id")
> +filename=$(notmuch search --output=files "id:$id")
> +test_expect_equal "$output" "(((((id \"sexp-show-inline-attachment-filename at notmuchmail.org\") (match t) (excluded nil) (filename \"$filename\") (timestamp 946728000) (date_relative \"2000-01-01\") (tags (\"inbox\")) (headers ((Subject \"sexp-show-inline-attachment-filename\") (From \"Notmuch Test Suite <test_suite at notmuchmail.org>\") (To \"test_suite at notmuchmail.org\") (Date \"Sat, 01 Jan 2000 12:00:00 +0000\"))) (body (((id 1) (content-type \"multipart/mixed\") (content (((id 2) (content-type \"text/plain\") (content \"This is a test message with inline attachment with a filename\")) ((id 3) (content-type \"application/octet-stream\") (filename \"README\")))))))) ())))"
> +
> +test_begin_subtest "Search message: sexp, utf-8"
> +add_message "[subject]=\"sexp-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
> +output=$(notmuch search --format=sexp "jsön-search-méssage" | notmuch_search_sanitize)
> +test_expect_equal "$output" "(((thread \"0000000000000005\") (timestamp 946728000) (date_relative \"2000-01-01\") (matched 1) (total 1) (authors \"Notmuch Test Suite\") (subject \"sexp-search-utf8-body-sübjéct\") (tags (\"inbox\" \"unread\"))))"
> +
> +
> +test_done
> --
> 1.8.0
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
More information about the notmuch
mailing list