From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B0BEE431FD4 for ; Thu, 6 Dec 2012 03:45:28 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: 0.001 X-Spam-Level: X-Spam-Status: No, score=0.001 tagged_above=-999 required=5 tests=[FREEMAIL_FROM=0.001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j4s9hC8MXK58 for ; Thu, 6 Dec 2012 03:45:26 -0800 (PST) Received: from mail.nexoid.at (www.nexoid.at [178.79.130.240]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id ADD26431FC3 for ; Thu, 6 Dec 2012 03:45:21 -0800 (PST) Received: by mail.nexoid.at (Postfix, from userid 1000) id 4FCB411C110; Thu, 6 Dec 2012 12:45:14 +0100 (CET) From: Peter Feigl To: notmuch@notmuchmail.org Subject: [PATCH v4 4/5] Adding tests for --format=sexp. Date: Thu, 6 Dec 2012 12:44:58 +0100 Message-Id: <2e05638af4ddc1f93f8b4fc5dde7c5d2fde8cda6.1354794428.git.craven@gmx.net> X-Mailer: git-send-email 1.8.0 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2012 11:45:29 -0000 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..b804942 --- /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@notmuchmail.org\"" "[reply-to]=\"test_suite+replyto@notmuchmail.org\"" "[body]=\"sexp-show-message\"" +output=$(notmuch show --format=sexp "sexp-show-message") +test_expect_equal "$output" "((((:id \"${gen_msg_id}\" :match t :excluded nil :filename \"${gen_msg_filename}\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject \"sexp-show-subject\" :From \"Notmuch Test Suite \" :To \"Notmuch Test Suite \" :Bcc \"test_suite+bcc@notmuchmail.org\" :Reply-To \"test_suite+replyto@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 \"${gen_msg_id}\" :match t :excluded nil :filename \"${gen_msg_filename}\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject \"sexp-show-subject\" :From \"Notmuch Test Suite \" :To \"Notmuch Test Suite \" :Bcc \"test_suite+bcc@notmuchmail.org\" :Reply-To \"test_suite+replyto@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 \"${gen_msg_id}\" :match t :excluded nil :filename \"${gen_msg_filename}\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject \"sexp-show-subject\" :From \"Notmuch Test Suite \" :To \"Notmuch Test Suite \" :Bcc \"test_suite+bcc@notmuchmail.org\" :Reply-To \"test_suite+replyto@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 \"${gen_msg_id}\" :match t :excluded nil :filename \"${gen_msg_filename}\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\" \"unread\") :headers (:Subject \"sexp-show-utf8-body-sübjéct\" :From \"Notmuch Test Suite \" :To \"Notmuch Test Suite \" :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@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 \"$id\" :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 \" :To \"test_suite@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