From c733f9e7207335c98b3e317ee64dcb38339fd5c2 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Thu, 6 Dec 2012 08:18:28 +0000 Subject: [PATCH] Re: [PATCH v3 4/5] Adding tests for --format=sexp. --- 99/e0525d9bfbf8af0a9b618b81ab8bdb08978176 | 223 ++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 99/e0525d9bfbf8af0a9b618b81ab8bdb08978176 diff --git a/99/e0525d9bfbf8af0a9b618b81ab8bdb08978176 b/99/e0525d9bfbf8af0a9b618b81ab8bdb08978176 new file mode 100644 index 000000000..c1ed0469b --- /dev/null +++ b/99/e0525d9bfbf8af0a9b618b81ab8bdb08978176 @@ -0,0 +1,223 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 82766431FB6 + for ; Thu, 6 Dec 2012 00:18:32 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 JMws9JjzeCnn for ; + Thu, 6 Dec 2012 00:18:30 -0800 (PST) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 7F82F431FAE + for ; Thu, 6 Dec 2012 00:18:30 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1TgWf2-0002IT-FD; Thu, 06 Dec 2012 08:18:26 +0000 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1TgWf1-0007XD-UF; Thu, 06 Dec 2012 08:18:24 +0000 +From: Mark Walters +To: Peter Feigl , notmuch@notmuchmail.org +Subject: Re: [PATCH v3 4/5] Adding tests for --format=sexp. +In-Reply-To: <1354779189-12231-5-git-send-email-craven@gmx.net> +References: <1354779189-12231-1-git-send-email-craven@gmx.net> + <1354779189-12231-5-git-send-email-craven@gmx.net> +User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Thu, 06 Dec 2012 08:18:28 +0000 +Message-ID: <87y5hbpp9n.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: c56bcfe8ec65f4411b0c2760051ad77a (of first 20000 bytes) +X-SpamAssassin-Score: -1.7 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.7 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * 0.6 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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 08:18:32 -0000 + +On Thu, 06 Dec 2012, Peter Feigl 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=3D" +> excludes +> tagging +> json +> + sexp +> text +> multipart +> thread-naming +> diff --git a/test/sexp b/test/sexp +> new file mode 100755 +> index 0000000..335844e +> --- /dev/null +> +++ b/test/sexp +> @@ -0,0 +1,48 @@ +> +#!/usr/bin/env bash +> +test_description=3D"--format=3Dsexp output" +> +. ./test-lib.sh +> + +> +test_begin_subtest "Show message: sexp" +> +add_message "[subject]=3D\"sexp-show-subject\"" "[date]=3D\"Sat, 01 Jan = +2000 12:00:00 -0000\"" "[bcc]=3D\"test_suite+bcc@notmuchmail.org\"" "[reply= +-to]=3D\"test_suite+replyto@notmuchmail.org\"" "[body]=3D\"sexp-show-messag= +e\"" +> +output=3D$(notmuch show --format=3Dsexp "sexp-show-message") +> +test_expect_equal "$output" "((((:id \"msg-001@notmuch-test-suite\" :mat= +ch t :excluded nil :filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/ms= +g-001\" :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\"= +))) ())))" + +The :filename above is hardcoded (so will fail for most of us). I know +there are some variables/functions for things like that but I am not +sure exactly which bits need to be wrapped. I think message-id and +thread-id are often a problem too. + +Best wishes + +Mark + + +> + +> +# This should be the same output as above. +> +test_begin_subtest "Show message: sexp --body=3Dtrue" +> +output=3D$(notmuch show --format=3Dsexp --body=3Dtrue "sexp-show-message= +") +> +test_expect_equal "$output" "((((:id \"msg-001@notmuch-test-suite\" :mat= +ch t :excluded nil :filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/ms= +g-001\" :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=3Dfalse" +> +output=3D$(notmuch show --format=3Dsexp --body=3Dfalse "sexp-show-messag= +e") +> +test_expect_equal "$output" "((((:id \"msg-001@notmuch-test-suite\" :mat= +ch t :excluded nil :filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/ms= +g-001\" :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]=3D\"sexp-search-subject\"" "[date]=3D\"Sat, 01 Ja= +n 2000 12:00:00 -0000\"" "[body]=3D\"sexp-search-message\"" +> +output=3D$(notmuch search --format=3Dsexp "sexp-search-message" | notmuc= +h_search_sanitize) +> +test_expect_equal "$output" "((:thread \"0000000000000002\" :timestamp 9= +46728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmu= +ch Test Suite\" :subject \"sexp-search-subject\" :tags (\"inbox\" \"unread\= +")))" +> + +> +test_begin_subtest "Show message: sexp, utf-8" +> +add_message "[subject]=3D\"sexp-show-utf8-body-s=C3=BCbj=C3=A9ct\"" "[da= +te]=3D\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=3D\"js=C3=B6n-show-m=C3= +=A9ssage\"" +> +output=3D$(notmuch show --format=3Dsexp "js=C3=B6n-show-m=C3=A9ssage") +> +test_expect_equal "$output" "((((:id \"msg-003@notmuch-test-suite\" :mat= +ch t :excluded nil :filename \"/home/nex/notmuch-sexp/test/tmp.sexp/mail/ms= +g-003\" :timestamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\"= + \"unread\") :headers (:Subject \"sexp-show-utf8-body-s=C3=BCbj=C3=A9ct\" := +>From \"Notmuch Test Suite \" :To \"Notmuch Test= + Suite \" :Date \"Sat, 01 Jan 2000 12:00:00 +00= +00\") :body ((:id 1 :content-type \"text/plain\" :content \"js=C3=B6n-show-= +m=C3=A9ssage\n\"))) ())))" +> + +> +test_begin_subtest "Show message: sexp, inline attachment filename" +> +subject=3D'sexp-show-inline-attachment-filename' +> +id=3D"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=3D$(notmuch show --format=3Dsexp "id:$id") +> +filename=3D$(notmuch search --output=3Dfiles "id:$id") +> +test_expect_equal "$output" "((((:id \"sexp-show-inline-attachment-filen= +ame@notmuchmail.org\" :match t :excluded nil :filename \"$filename\" :times= +tamp 946728000 :date_relative \"2000-01-01\" :tags (\"inbox\") :headers (:S= +ubject \"sexp-show-inline-attachment-filename\" :From \"Notmuch Test Suite = +\" :To \"test_suite@notmuchmail.org\" :Date \"S= +at, 01 Jan 2000 12:00:00 +0000\") :body ((:id 1 :content-type \"multipart/m= +ixed\" :content ((:id 2 :content-type \"text/plain\" :content \"This is a t= +est 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]=3D\"sexp-search-utf8-body-s=C3=BCbj=C3=A9ct\"" "[= +date]=3D\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=3D\"js=C3=B6n-search-m= +=C3=A9ssage\"" +> +output=3D$(notmuch search --format=3Dsexp "js=C3=B6n-search-m=C3=A9ssage= +" | notmuch_search_sanitize) +> +test_expect_equal "$output" "((:thread \"0000000000000005\" :timestamp 9= +46728000 :date_relative \"2000-01-01\" :matched 1 :total 1 :authors \"Notmu= +ch Test Suite\" :subject \"sexp-search-utf8-body-s=C3=BCbj=C3=A9ct\" :tags = +(\"inbox\" \"unread\")))" +> + +> + +> +test_done +> --=20 +> 1.8.0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2