diff options
| author | David Bremner <bremner@debian.org> | 2012-06-17 07:38:59 -0300 |
|---|---|---|
| committer | David Bremner <bremner@debian.org> | 2012-06-17 07:38:59 -0300 |
| commit | 3dc2ff6fc73d3a057ae0a3f350c42b077d7ec273 (patch) | |
| tree | 19322fd5112777d877a7e31eef3efbc4ac0ef6cd /test | |
| parent | 3b1e8a200dd4740b3c5605256e1535a681367347 (diff) | |
| parent | 2ef24acf03fdd73e39d2c233016e71f194affbcf (diff) | |
Merge branch 'release' into squeeze-backports
Conflicts:
debian/changelog
Diffstat (limited to 'test')
28 files changed, 985 insertions, 118 deletions
diff --git a/test/config b/test/config new file mode 100755 index 00000000..93ecb139 --- /dev/null +++ b/test/config @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +test_description='"notmuch config"' +. test-lib.sh + +test_begin_subtest "Get string value" +test_expect_equal "$(notmuch config get user.name)" "Notmuch Test Suite" + +test_begin_subtest "Get list value" +test_expect_equal "$(notmuch config get new.tags)" "\ +unread +inbox" + +test_begin_subtest "Set string value" +notmuch config set foo.string "this is a string value" +test_expect_equal "$(notmuch config get foo.string)" "this is a string value" + +test_begin_subtest "Set string value again" +notmuch config set foo.string "this is another string value" +test_expect_equal "$(notmuch config get foo.string)" "this is another string value" + +test_begin_subtest "Set list value" +notmuch config set foo.list this "is a" "list value" +test_expect_equal "$(notmuch config get foo.list)" "\ +this +is a +list value" + +test_begin_subtest "Set list value again" +notmuch config set foo.list this "is another" "list value" +test_expect_equal "$(notmuch config get foo.list)" "\ +this +is another +list value" + +test_begin_subtest "Remove key" +notmuch config set foo.remove baz +notmuch config set foo.remove +test_expect_equal "$(notmuch config get foo.remove)" "" + +test_begin_subtest "Remove non-existent key" +notmuch config set foo.nonexistent +test_expect_equal "$(notmuch config get foo.nonexistent)" "" + +test_begin_subtest "List all items" +notmuch config set database.path "/canonical/path" +output=$(notmuch config list) +test_expect_equal "$output" "\ +database.path=/canonical/path +user.name=Notmuch Test Suite +user.primary_email=test_suite@notmuchmail.org +user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org +new.tags=unread;inbox; +new.ignore= +search.exclude_tags= +maildir.synchronize_flags=true +foo.string=this is another string value +foo.list=this;is another;list value;" + +test_done diff --git a/test/crypto b/test/crypto index 6723ef87..be752b19 100755 --- a/test/crypto +++ b/test/crypto @@ -43,6 +43,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -50,9 +51,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "good", "fingerprint": "'$FINGERPRINT'", @@ -77,6 +77,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -84,9 +85,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "good", "fingerprint": "'$FINGERPRINT'", @@ -111,6 +111,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -118,9 +119,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "error", "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'", @@ -151,7 +151,7 @@ test_begin_subtest "decryption, --format=text" output=$(notmuch show --format=text --decrypt subject:"test encrypted message 001" \ | notmuch_show_sanitize_all \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') -expected='message{ id:XXXXX depth:0 match:1 filename:XXXXX +expected='message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2000-01-01) (encrypted inbox) Subject: test encrypted message 001 @@ -185,6 +185,7 @@ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 00 | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -192,9 +193,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test encrypted message 001", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "encstatus": [{"status": "good"}], "sigstatus": [], @@ -240,6 +240,7 @@ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 00 | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -247,9 +248,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test encrypted message 001", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "encstatus": [{"status": "bad"}], "content-type": "multipart/encrypted", @@ -275,6 +275,7 @@ output=$(notmuch show --format=json --decrypt subject:"test encrypted message 00 | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -282,9 +283,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test encrypted message 002", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "encstatus": [{"status": "good"}], "sigstatus": [{"status": "good", @@ -330,6 +330,7 @@ output=$(notmuch show --format=json --verify subject:"test signed message 001" \ | sed -e 's|"created": [1234567890]*|"created": 946728000|') expected='[[[{"id": "XXXXX", "match": true, + "excluded": false, "filename": "YYYYY", "timestamp": 946728000, "date_relative": "2000-01-01", @@ -337,9 +338,8 @@ expected='[[[{"id": "XXXXX", "headers": {"Subject": "test signed message 001", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "test_suite@notmuchmail.org", - "Cc": "", - "Bcc": "", - "Date": "01 Jan 2000 12:00:00 -0000"}, + "Date": "Sat, + 01 Jan 2000 12:00:00 +0000"}, "body": [{"id": 1, "sigstatus": [{"status": "error", "keyid": "6D92612D94E46381", @@ -39,7 +39,7 @@ test_begin_subtest "Navigation of notmuch-hello to search results" test_emacs '(notmuch-hello) (goto-char (point-min)) (re-search-forward "inbox") - (widget-button-press (point)) + (widget-button-press (1- (point))) (notmuch-test-wait) (test-output)' test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox @@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads subject:message-with-invalid-from) test_emacs "(notmuch-show \"$thread\") (test-output)" cat <<EOF >EXPECTED -Invalid " From <test_suite@notmuchmail.org> (2001-01-05) (inbox) +"Invalid " (2001-01-05) (inbox) Subject: message-with-invalid-from To: Notmuch Test Suite <test_suite@notmuchmail.org> Date: Fri, 05 Jan 2001 15:43:57 +0000 @@ -139,6 +139,17 @@ test_emacs '(notmuch-search "id:\"123..456@example\"") output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)" +test_begin_subtest "Message with quote in Message-Id:" +add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"' +test_emacs '(notmuch-search "subject:\"Message with quote\"") + (notmuch-test-wait) + (execute-kbd-macro "+search-add") + (notmuch-search-show-thread) + (notmuch-test-wait) + (execute-kbd-macro "+show-add")' +output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with quote in Message-Id (inbox search-add show-add)" + test_begin_subtest "Sending a message via (fake) SMTP" emacs_deliver_message \ 'Testing message sent via SMTP' \ @@ -256,39 +267,227 @@ EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "Reply within emacs" -test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"") +test_emacs '(let ((message-hidden-headers ''())) + (notmuch-search "subject:\"testing message sent via SMTP\"") (notmuch-test-wait) (notmuch-search-reply-to-thread) - (test-output)' + (test-output))' sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT +sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT +sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT cat <<EOF >EXPECTED From: Notmuch Test Suite <test_suite@notmuchmail.org> To: user@example.com Subject: Re: Testing message sent via SMTP In-Reply-To: <XXX> Fcc: ${MAIL_DIR}/sent +References: <XXX> +User-Agent: Notmuch/XXX Emacs/XXX --text follows this line-- -On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote: +Notmuch Test Suite <test_suite@notmuchmail.org> writes: + > This is a test that messages are sent via SMTP EOF test_expect_equal_file OUTPUT EXPECTED +test_begin_subtest "Reply from alternate address within emacs" +add_message '[from]="Sender <sender@example.com>"' \ + [to]=test_suite_other@notmuchmail.org + +test_emacs "(let ((message-hidden-headers '())) + (notmuch-search \"id:\\\"${gen_msg_id}\\\"\") + (notmuch-test-wait) + (notmuch-search-reply-to-thread) + (test-output))" +sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT +cat <<EOF >EXPECTED +From: Notmuch Test Suite <test_suite_other@notmuchmail.org> +To: Sender <sender@example.com> +Subject: Re: ${test_subtest_name} +In-Reply-To: <${gen_msg_id}> +Fcc: ${MAIL_DIR}/sent +References: <${gen_msg_id}> +User-Agent: Notmuch/XXX Emacs/XXX +--text follows this line-- +Sender <sender@example.com> writes: + +> This is just a test message (#${gen_msg_cnt}) +EOF +test_expect_equal_file OUTPUT EXPECTED + +test_begin_subtest "Reply from address in named group list within emacs" +add_message '[from]="Sender <sender@example.com>"' \ + '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \ + [cc]=test_suite_other@notmuchmail.org + +test_emacs "(let ((message-hidden-headers '())) + (notmuch-search \"id:\\\"${gen_msg_id}\\\"\") + (notmuch-test-wait) + (notmuch-search-reply-to-thread) + (test-output))" +sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT +cat <<EOF >EXPECTED +From: Notmuch Test Suite <test_suite@notmuchmail.org> +To: Sender <sender@example.com>, someone@example.com +Subject: Re: ${test_subtest_name} +In-Reply-To: <${gen_msg_id}> +Fcc: ${MAIL_DIR}/sent +References: <${gen_msg_id}> +User-Agent: Notmuch/XXX Emacs/XXX +--text follows this line-- +Sender <sender@example.com> writes: + +> This is just a test message (#${gen_msg_cnt}) +EOF +test_expect_equal_file OUTPUT EXPECTED + +test_begin_subtest "Reply within emacs to a multipart/mixed message" +test_emacs '(let ((message-hidden-headers ''())) + (notmuch-show "id:20091118002059.067214ed@hikari") + (notmuch-show-reply) + (test-output))' +sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT +cat <<EOF >EXPECTED +From: Notmuch Test Suite <test_suite@notmuchmail.org> +To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org +Subject: Re: [notmuch] Introducing myself +In-Reply-To: <20091118002059.067214ed@hikari> +Fcc: ${MAIL_DIR}/sent +References: <20091118002059.067214ed@hikari> +User-Agent: Notmuch/XXX Emacs/XXX +--text follows this line-- +Adrian Perez de Castro <aperez@igalia.com> writes: + +> Hello to all, +> +> I have just heard about Not Much today in some random Linux-related news +> site (LWN?), my name is Adrian Perez and I work as systems administrator +> (although I can do some code as well :P). I have always thought that the +> ideas behind Sup were great, but after some time using it, I got tired of +> the oddities that it has. I also do not like doing things like having to +> install Ruby just for reading and sorting mails. Some time ago I thought +> about doing something like Not Much and in fact I played a bit with the +> Python+Xapian and the Python+Whoosh combinations, because I find relaxing +> to code things in Python when I am not working and also it is installed +> by default on most distribution. I got to have some mailboxes indexed and +> basic searching working a couple of months ago. Lately I have been very +> busy and had no time for coding, and them... boom! Not Much appears -- and +> it is almost exactly what I was trying to do, but faster. I have been +> playing a bit with Not Much today, and I think it has potential. +> +> Also, I would like to share one idea I had in mind, that you might find +> interesting: One thing I have found very annoying is having to re-tag my +> mail when the indexes get b0rked (it happened a couple of times to me while +> using Sup), so I was planning to mails as read/unread and adding the tags +> not just to the index, but to the mail text itself, e.g. by adding a +> "X-Tags" header field or by reusing the "Keywords" one. This way, the index +> could be totally recreated by re-reading the mail directories, and this +> would also allow to a tools like OfflineIMAP [1] to get the mails into a +> local maildir, tagging and indexing the mails with the e-mail reader and +> then syncing back the messages with the "X-Tags" header to the IMAP server. +> This would allow to use the mail reader from a different computer and still +> have everything tagged finely. +> +> Best regards, +> +> +> --- +> [1] http://software.complete.org/software/projects/show/offlineimap +> +> -- +> Adrian Perez de Castro <aperez@igalia.com> +> Igalia - Free Software Engineering +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch +EOF +test_expect_equal_file OUTPUT EXPECTED + +test_begin_subtest "Reply within emacs to a multipart/alternative message" +test_emacs '(let ((message-hidden-headers ''())) + (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") + (notmuch-show-reply) + (test-output))' +sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT +cat <<EOF >EXPECTED +From: Notmuch Test Suite <test_suite@notmuchmail.org> +To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org +Subject: Re: [notmuch] preliminary FreeBSD support +In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com> +Fcc: ${MAIL_DIR}/sent +References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com> +User-Agent: Notmuch/XXX Emacs/XXX +--text follows this line-- +Alex Botero-Lowry <alex.boterolowry@gmail.com> writes: + +> I saw the announcement this morning, and was very excited, as I had been +> hoping sup would be turned into a library, +> since I like the concept more than the UI (I'd rather an emacs interface). +> +> I did a preliminary compile which worked out fine, but +> sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on +> FreeBSD, so notmuch_config_open segfaulted. +> +> Attached is a patch that supplies a default buffer size of 64 in cases where +> -1 is returned. +> +> http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this +> is acceptable behavior, +> and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically +> uses 64 as the +> buffer size. +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch +EOF +test_expect_equal_file OUTPUT EXPECTED + +test_begin_subtest "Reply within emacs to an html-only message" +add_message '[content-type]="text/html"' \ + '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"' +test_emacs "(let ((message-hidden-headers '()) (mm-text-html-renderer 'html2text)) + (notmuch-show \"id:${gen_msg_id}\") + (notmuch-show-reply) + (test-output))" +sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT +cat <<EOF >EXPECTED +From: Notmuch Test Suite <test_suite@notmuchmail.org> +To: +Subject: Re: Reply within emacs to an html-only message +In-Reply-To: <${gen_msg_id}> +Fcc: ${MAIL_DIR}/sent +References: <${gen_msg_id}> +User-Agent: Notmuch/XXX Emacs/XXX +--text follows this line-- +Notmuch Test Suite <test_suite@notmuchmail.org> writes: + +> Hi,This is an HTML test message.OK? +EOF +test_expect_equal_file OUTPUT EXPECTED + test_begin_subtest "Quote MML tags in reply" message_id='test-emacs-mml-quoting@message.id' add_message [id]="$message_id" \ "[subject]='$test_subtest_name'" \ '[body]="<#part disposition=inline>"' -test_emacs "(notmuch-show \"id:$message_id\") +test_emacs "(let ((message-hidden-headers '())) + (notmuch-show \"id:$message_id\") (notmuch-show-reply) - (test-output)" + (test-output))" +sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT cat <<EOF >EXPECTED From: Notmuch Test Suite <test_suite@notmuchmail.org> To: Subject: Re: Quote MML tags in reply In-Reply-To: <test-emacs-mml-quoting@message.id> Fcc: ${MAIL_DIR}/sent +References: <test-emacs-mml-quoting@message.id> +User-Agent: Notmuch/XXX Emacs/XXX --text follows this line-- -On Fri, 05 Jan 2001 15:43:57 +0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote: +Notmuch Test Suite <test_suite@notmuchmail.org> writes: + > <#!part disposition=inline> EOF test_expect_equal_file OUTPUT EXPECTED @@ -414,7 +613,7 @@ test_emacs '(notmuch-show "id:\"bought\"") (reverse-region (point-min) (point-max)) (test-output)' cat <<EOF >EXPECTED -Sat, 01 Jan 2000 12:00:00 -0000 +Sat, 01 Jan 2000 12:00:00 +0000 Some One <someone@somewhere.org> Some One Else <notsomeone@somewhere.org> Notmuch <notmuch@notmuchmail.org> diff --git a/test/emacs-hello b/test/emacs-hello new file mode 100755 index 00000000..a998dc4f --- /dev/null +++ b/test/emacs-hello @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +test_description="Testing emacs notmuch-hello view" +. test-lib.sh + +EXPECTED=$TEST_DIRECTORY/emacs.expected-output + +add_email_corpus + +test_begin_subtest "User-defined section with inbox tag" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-searches + \"Test\" '((\"inbox\" . \"tag:inbox\"))))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-new-section + +test_begin_subtest "User-defined section with empty, hidden entry" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-searches + \"Test-with-empty\" + '((\"inbox\" . \"tag:inbox\") + (\"doesnotexist\" . \"tag:doesnotexist\")) + :hide-empty-searches t))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-with-empty + +test_begin_subtest "User-defined section, unread tag filtered out" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-tags-section + \"Test-with-filtered\" + :hide-tags '(\"unread\")))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-hidden-tag + +test_begin_subtest "User-defined section, different query for counts" +test_emacs "(let ((notmuch-hello-sections + (list (lambda () (notmuch-hello-insert-tags-section + \"Test-with-counts\" + :filter-count \"tag:signed\"))))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-counts + +test_begin_subtest "Empty custom tags section" +test_emacs "(let* ((widget (widget-create 'notmuch-hello-tags-section)) + (notmuch-hello-sections (list (widget-value widget)))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-empty-custom-tags-section + +test_begin_subtest "Empty custom queries section" +test_emacs "(let* ((widget (widget-create 'notmuch-hello-query-section)) + (notmuch-hello-sections (list (widget-value widget)))) + (notmuch-hello) + (test-output))" +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-empty-custom-queries-section + +test_begin_subtest "Column alignment for tag/queries with long names" +tag=a-very-long-tag # length carefully calculated for 80 characters window width +notmuch tag +$tag '*' +test_emacs '(notmuch-hello) + (test-output)' +notmuch tag -$tag '*' +test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-long-names + +test_done diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello index 3e59595f..2d698917 100644 --- a/test/emacs.expected-output/notmuch-hello +++ b/test/emacs.expected-output/notmuch-hello @@ -2,13 +2,14 @@ Saved searches: [edit] - 52 inbox 52 unread + 52 inbox 52 unread Search: . -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' to refresh this screen. `s' to search messages. `q' to quit. + Customize this page. diff --git a/test/emacs.expected-output/notmuch-hello-empty-custom-queries-section b/test/emacs.expected-output/notmuch-hello-empty-custom-queries-section new file mode 100644 index 00000000..cd0fdf08 --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-empty-custom-queries-section @@ -0,0 +1,3 @@ +: [hide] + + diff --git a/test/emacs.expected-output/notmuch-hello-empty-custom-tags-section b/test/emacs.expected-output/notmuch-hello-empty-custom-tags-section new file mode 100644 index 00000000..b56fd671 --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-empty-custom-tags-section @@ -0,0 +1,5 @@ +: [hide] + + 4 attachment 7 signed + 52 inbox 52 unread + diff --git a/test/emacs.expected-output/notmuch-hello-long-names b/test/emacs.expected-output/notmuch-hello-long-names new file mode 100644 index 00000000..486d0d9a --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-long-names @@ -0,0 +1,18 @@ + Welcome to notmuch. You have 52 messages. + +Saved searches: [edit] + + 52 inbox 52 unread + +Search: . + +All tags: [hide] + + 52 a-very-long-tag 52 inbox 52 unread + 4 attachment 7 signed + + Type a search query and hit RET to view matching threads. + Edit saved searches with the `edit' button. + Hit RET or click on a saved search or tag name to view matching threads. + `=' to refresh this screen. `s' to search messages. `q' to quit. + Customize this page. diff --git a/test/emacs.expected-output/notmuch-hello-new-section b/test/emacs.expected-output/notmuch-hello-new-section new file mode 100644 index 00000000..67fdef24 --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-new-section @@ -0,0 +1,4 @@ +Test: [hide] + + 52 inbox + diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches b/test/emacs.expected-output/notmuch-hello-no-saved-searches index ef0e5d05..05475b15 100644 --- a/test/emacs.expected-output/notmuch-hello-no-saved-searches +++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches @@ -2,9 +2,10 @@ Search: . -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' to refresh this screen. `s' to search messages. `q' to quit. + Customize this page. diff --git a/test/emacs.expected-output/notmuch-hello-section-counts b/test/emacs.expected-output/notmuch-hello-section-counts new file mode 100644 index 00000000..7a9827cf --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-section-counts @@ -0,0 +1,5 @@ +Test-with-counts: [hide] + + 2 attachment 7 signed + 7 inbox 7 unread + diff --git a/test/emacs.expected-output/notmuch-hello-section-hidden-tag b/test/emacs.expected-output/notmuch-hello-section-hidden-tag new file mode 100644 index 00000000..809a1142 --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-section-hidden-tag @@ -0,0 +1,4 @@ +Test-with-filtered: [hide] + + 4 attachment 52 inbox 7 signed + diff --git a/test/emacs.expected-output/notmuch-hello-section-with-empty b/test/emacs.expected-output/notmuch-hello-section-with-empty new file mode 100644 index 00000000..5c673179 --- /dev/null +++ b/test/emacs.expected-output/notmuch-hello-section-with-empty @@ -0,0 +1,4 @@ +Test-with-empty: [hide] + + 52 inbox + diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty index 71edba73..854e0c2a 100644 --- a/test/emacs.expected-output/notmuch-hello-with-empty +++ b/test/emacs.expected-output/notmuch-hello-with-empty @@ -2,13 +2,14 @@ Saved searches: [edit] - 52 inbox 52 unread 0 empty + 52 inbox 52 unread 0 empty Search: . -[Show all tags] +All tags: [show] Type a search query and hit RET to view matching threads. Edit saved searches with the `edit' button. Hit RET or click on a saved search or tag name to view matching threads. `=' to refresh this screen. `s' to search messages. `q' to quit. + Customize this page. diff --git a/test/encoding b/test/encoding index f0d073c5..2e1326eb 100755 --- a/test/encoding +++ b/test/encoding @@ -6,10 +6,10 @@ test_begin_subtest "Message with text of unknown charset" add_message '[content-type]="text/plain; charset=unknown-8bit"' \ "[body]=irrelevant" output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize) -test_expect_equal "$output" "message{ id:msg-001@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-001 +test_expect_equal "$output" "message{ id:msg-001@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-001 header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox unread) -Subject: Test message #1 +Subject: Message with text of unknown charset From: Notmuch Test Suite <test_suite@notmuchmail.org> To: Notmuch Test Suite <test_suite@notmuchmail.org> Date: Fri, 05 Jan 2001 15:43:57 +0000 diff --git a/test/excludes b/test/excludes new file mode 100755 index 00000000..24d653ea --- /dev/null +++ b/test/excludes @@ -0,0 +1,423 @@ +#!/usr/bin/env bash +test_description='"notmuch search, count and show" with excludes in several variations' +. ./test-lib.sh + +# Generates a thread consisting of a top level message and 'length' +# replies. The subject of the top message 'subject: top message" +# and the subject of the nth reply in the thread is "subject: reply n" +generate_thread () +{ + local subject="$1" + local length="$2" + generate_message '[subject]="'"${subject}: top message"'"' '[body]="'"body of top message"'"' + parent_id=$gen_msg_id + gen_thread_msg_id[0]=$gen_msg_id + for i in `seq 1 $length` + do + generate_message '[subject]="'"${subject}: reply $i"'"' \ + "[in-reply-to]=\<$parent_id\>" \ + '[body]="'"body of reply $i"'"' + gen_thread_msg_id[$i]=$gen_msg_id + parent_id=$gen_msg_id + done + notmuch new > /dev/null + # We cannot retrieve the thread_id until after we have run notmuch new. + gen_thread_id=`notmuch search --output=threads id:${gen_thread_msg_id[0]}` +} + +############################################# +# These are the original search exclude tests. + +test_begin_subtest "Search, exclude \"deleted\" messages from search" +notmuch config set search.exclude_tags deleted +generate_message '[subject]="Not deleted"' +not_deleted_id=$gen_msg_id +generate_message '[subject]="Deleted"' +notmuch new > /dev/null +notmuch tag +deleted id:$gen_msg_id +deleted_id=$gen_msg_id +output=$(notmuch search subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)" + +test_begin_subtest "Search, exclude \"deleted\" messages from message search" +output=$(notmuch search --output=messages subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "id:$not_deleted_id" + +test_begin_subtest "Search, exclude \"deleted\" messages from message search --exclude=false" +output=$(notmuch search --exclude=false --output=messages subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "id:$not_deleted_id +id:$deleted_id" + +test_begin_subtest "Search, exclude \"deleted\" messages from message search (non-existent exclude-tag)" +notmuch config set search.exclude_tags deleted non_existent_tag +output=$(notmuch search --output=messages subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "id:$not_deleted_id" +notmuch config set search.exclude_tags deleted + +test_begin_subtest "Search, exclude \"deleted\" messages from search, overridden" +output=$(notmuch search subject:deleted and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Deleted (deleted inbox unread)" + +test_begin_subtest "Search, exclude \"deleted\" messages from threads" +add_message '[subject]="Not deleted reply"' '[in-reply-to]="<$gen_msg_id>"' +output=$(notmuch search subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) +thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)" + +test_begin_subtest "Search, don't exclude \"deleted\" messages when --exclude=flag specified" +output=$(notmuch search --exclude=flag subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) +thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)" + +test_begin_subtest "Search, don't exclude \"deleted\" messages from search if not configured" +notmuch config set search.exclude_tags +output=$(notmuch search subject:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) +thread:XXX 2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox unread)" + + +######################################################## +# We construct some threads for the tests. We use the tag "test" to +# indicate which messages we will search for. + +# A thread of deleted messages; test matches one of them. +generate_thread "All messages excluded: single match" 5 +notmuch tag +deleted $gen_thread_id +notmuch tag +test id:${gen_thread_msg_id[2]} + +# A thread of deleted messages; test matches two of them. +generate_thread "All messages excluded: double match" 5 +notmuch tag +deleted $gen_thread_id +notmuch tag +test id:${gen_thread_msg_id[2]} +notmuch tag +test id:${gen_thread_msg_id[4]} + +# A thread some messages deleted; test only matches a deleted message. +generate_thread "Some messages excluded: single excluded match" 5 +notmuch tag +deleted +test id:${gen_thread_msg_id[3]} + +# A thread some messages deleted; test only matches a non-deleted message. +generate_thread "Some messages excluded: single non-excluded match" 5 +notmuch tag +deleted id:${gen_thread_msg_id[2]} +notmuch tag +test id:${gen_thread_msg_id[4]} + +# A thread no messages deleted; test matches a message. +generate_thread "No messages excluded: single match" 5 +notmuch tag +test id:${gen_thread_msg_id[3]} + +# Temporarily remove excludes to get list of matching messages +notmuch config set search.exclude_tags +matching_message_ids=( `notmuch search --output=messages tag:test` ) +notmuch config set search.exclude_tags deleted + +######################################### +# Notmuch search tests + +test_begin_subtest "Search, default exclusion (thread summary)" +output=$(notmuch search tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single non-excluded match: reply 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)" + +test_begin_subtest "Search, default exclusion (messages)" +output=$(notmuch search --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[4]} +${matching_message_ids[5]}" + +test_begin_subtest "Search, exclude=true (thread summary)" +output=$(notmuch search --exclude=true tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single non-excluded match: reply 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)" + +test_begin_subtest "Search, exclude=true (messages)" +output=$(notmuch search --exclude=true --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[4]} +${matching_message_ids[5]}" + +test_begin_subtest "Search, exclude=false (thread summary)" +output=$(notmuch search --exclude=false tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/6] Notmuch Test Suite; All messages excluded: double match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single non-excluded match: reply 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)" + +test_begin_subtest "Search, exclude=false (messages)" +output=$(notmuch search --exclude=false --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]} +${matching_message_ids[4]} +${matching_message_ids[5]}" + +test_begin_subtest "Search, exclude=flag (thread summary)" +output=$(notmuch search --exclude=flag tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [0/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [0/6] Notmuch Test Suite; All messages excluded: double match: reply 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [0/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single non-excluded match: reply 4 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)" + +test_begin_subtest "Search, exclude=flag (messages)" +output=$(notmuch search --exclude=flag --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]} +${matching_message_ids[4]} +${matching_message_ids[5]}" + +test_begin_subtest "Search, default exclusion: tag in query (thread summary)" +output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/6] Notmuch Test Suite; All messages excluded: double match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread)" + +test_begin_subtest "Search, default exclusion: tag in query (messages)" +output=$(notmuch search --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]}" + +test_begin_subtest "Search, exclude=true: tag in query (thread summary)" +output=$(notmuch search --exclude=true tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/6] Notmuch Test Suite; All messages excluded: double match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread)" + +test_begin_subtest "Search, exclude=true: tag in query (messages)" +output=$(notmuch search --exclude=true --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]}" + +test_begin_subtest "Search, exclude=false: tag in query (thread summary)" +output=$(notmuch search --exclude=false tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/6] Notmuch Test Suite; All messages excluded: double match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread)" + +test_begin_subtest "Search, exclude=false: tag in query (messages)" +output=$(notmuch search --exclude=false --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]}" + +test_begin_subtest "Search, exclude=flag: tag in query (thread summary)" +output=$(notmuch search --exclude=flag tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/6] Notmuch Test Suite; All messages excluded: double match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread)" + +test_begin_subtest "Search, exclude=flag: tag in query (messages)" +output=$(notmuch search --exclude=flag --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]}" + + +######################################################### +# Notmuch count tests + +test_begin_subtest "Count, default exclusion (messages)" +output=$(notmuch count tag:test) +test_expect_equal "$output" "2" + +test_begin_subtest "Count, default exclusion (threads)" +output=$(notmuch count --output=threads tag:test) +test_expect_equal "$output" "2" + +test_begin_subtest "Count, exclude=true (messages)" +output=$(notmuch count --exclude=true tag:test) +test_expect_equal "$output" "2" + +test_begin_subtest "Count, exclude=true (threads)" +output=$(notmuch count --output=threads --exclude=true tag:test) +test_expect_equal "$output" "2" + +test_begin_subtest "Count, exclude=false (messages)" +output=$(notmuch count --exclude=false tag:test) +test_expect_equal "$output" "6" + +test_begin_subtest "Count, exclude=false (threads)" +output=$(notmuch count --output=threads --exclude=false tag:test) +test_expect_equal "$output" "5" + +test_begin_subtest "Count, default exclusion: tag in query (messages)" +output=$(notmuch count tag:test and tag:deleted) +test_expect_equal "$output" "4" + +test_begin_subtest "Count, default exclusion: tag in query (threads)" +output=$(notmuch count --output=threads tag:test and tag:deleted) +test_expect_equal "$output" "3" + +test_begin_subtest "Count, exclude=true: tag in query (messages)" +output=$(notmuch count --exclude=true tag:test and tag:deleted) +test_expect_equal "$output" "4" + +test_begin_subtest "Count, exclude=true: tag in query (threads)" +output=$(notmuch count --output=threads --exclude=true tag:test and tag:deleted) +test_expect_equal "$output" "3" + +test_begin_subtest "Count, exclude=false: tag in query (messages)" +output=$(notmuch count --exclude=false tag:test and tag:deleted) +test_expect_equal "$output" "4" + +test_begin_subtest "Count, exclude=false: tag in query (threads)" +output=$(notmuch count --output=threads --exclude=false tag:test and tag:deleted) +test_expect_equal "$output" "3" + +############################################################# +# Show tests + +test_begin_subtest "Show, default exclusion" +output=$(notmuch show tag:test | notmuch_show_sanitize_all | egrep "Subject:|message{") +test_expect_equal "$output" "message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 4 +message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 3" + +test_begin_subtest "Show, default exclusion (entire-thread)" +output=$(notmuch show --entire-thread tag:test | notmuch_show_sanitize_all | egrep "Subject:|message{") +test_expect_equal "$output" "message{ id:XXXXX depth:0 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: top message +message{ id:XXXXX depth:1 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 1 +message{ id:XXXXX depth:2 match:0 excluded:1 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 2 +message{ id:XXXXX depth:3 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 3 +message{ id:XXXXX depth:4 match:1 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 5 +message{ id:XXXXX depth:0 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: top message +message{ id:XXXXX depth:1 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 1 +message{ id:XXXXX depth:2 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 2 +message{ id:XXXXX depth:3 match:1 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 3 +message{ id:XXXXX depth:4 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 5" + +test_begin_subtest "Show, exclude=true" +output=$(notmuch show --exclude=true tag:test | notmuch_show_sanitize_all | egrep "Subject:|message{") +test_expect_equal "$output" "message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 4 +message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 3" + +test_begin_subtest "Show, exclude=true (entire-thread)" +output=$(notmuch show --entire-thread --exclude=true tag:test | notmuch_show_sanitize_all | egrep "Subject:|message{") +test_expect_equal "$output" "message{ id:XXXXX depth:0 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: top message +message{ id:XXXXX depth:1 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 1 +message{ id:XXXXX depth:2 match:0 excluded:1 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 2 +message{ id:XXXXX depth:3 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 3 +message{ id:XXXXX depth:4 match:1 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 5 +message{ id:XXXXX depth:0 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: top message +message{ id:XXXXX depth:1 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 1 +message{ id:XXXXX depth:2 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 2 +message{ id:XXXXX depth:3 match:1 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 3 +message{ id:XXXXX depth:4 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 5" + +test_begin_subtest "Show, exclude=false" +output=$(notmuch show --exclude=false tag:test | notmuch_show_sanitize_all | egrep "Subject:|message{") +test_expect_equal "$output" "message{ id:XXXXX depth:0 match:1 excluded:1 filename:XXXXX +Subject: All messages excluded: single match: reply 2 +message{ id:XXXXX depth:0 match:1 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: reply 2 +message{ id:XXXXX depth:1 match:1 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: reply 4 +message{ id:XXXXX depth:0 match:1 excluded:1 filename:XXXXX +Subject: Some messages excluded: single excluded match: reply 3 +message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 4 +message{ id:XXXXX depth:0 match:1 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 3" + +test_begin_subtest "Show, exclude=false (entire-thread)" +output=$(notmuch show --entire-thread --exclude=false tag:test | notmuch_show_sanitize_all | egrep "Subject:|message{") +test_expect_equal "$output" "message{ id:XXXXX depth:0 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: single match: top message +message{ id:XXXXX depth:1 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: single match: reply 1 +message{ id:XXXXX depth:2 match:1 excluded:1 filename:XXXXX +Subject: All messages excluded: single match: reply 2 +message{ id:XXXXX depth:3 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: single match: reply 3 +message{ id:XXXXX depth:4 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: single match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: single match: reply 5 +message{ id:XXXXX depth:0 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: top message +message{ id:XXXXX depth:1 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: reply 1 +message{ id:XXXXX depth:2 match:1 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: reply 2 +message{ id:XXXXX depth:3 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: reply 3 +message{ id:XXXXX depth:4 match:1 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:1 filename:XXXXX +Subject: All messages excluded: double match: reply 5 +message{ id:XXXXX depth:0 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single excluded match: top message +message{ id:XXXXX depth:1 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single excluded match: reply 1 +message{ id:XXXXX depth:2 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single excluded match: reply 2 +message{ id:XXXXX depth:3 match:1 excluded:1 filename:XXXXX +Subject: Some messages excluded: single excluded match: reply 3 +message{ id:XXXXX depth:4 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single excluded match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single excluded match: reply 5 +message{ id:XXXXX depth:0 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: top message +message{ id:XXXXX depth:1 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 1 +message{ id:XXXXX depth:2 match:0 excluded:1 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 2 +message{ id:XXXXX depth:3 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 3 +message{ id:XXXXX depth:4 match:1 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:0 filename:XXXXX +Subject: Some messages excluded: single non-excluded match: reply 5 +message{ id:XXXXX depth:0 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: top message +message{ id:XXXXX depth:1 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 1 +message{ id:XXXXX depth:2 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 2 +message{ id:XXXXX depth:3 match:1 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 3 +message{ id:XXXXX depth:4 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 4 +message{ id:XXXXX depth:5 match:0 excluded:0 filename:XXXXX +Subject: No messages excluded: single match: reply 5" + + +test_done @@ -5,7 +5,7 @@ test_description="--format=json output" test_begin_subtest "Show message: json" add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\"" output=$(notmuch show --format=json "json-show-message") -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" +test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]" test_begin_subtest "Search message: json" add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\"" @@ -22,7 +22,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\", test_begin_subtest "Show message: json, utf-8" add_message "[subject]=\"json-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=json "jsön-show-méssage") -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]" +test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@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: json, inline attachment filename" subject='json-show-inline-attachment-filename' @@ -35,7 +35,7 @@ emacs_deliver_message \ (insert \"Message-ID: <$id>\n\")" output=$(notmuch show --format=json "id:$id") filename=$(notmuch search --output=files "id:$id") -test_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"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_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"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: json, utf-8" add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\"" diff --git a/test/maildir-sync b/test/maildir-sync index d5872a53..d72ec07e 100755 --- a/test/maildir-sync +++ b/test/maildir-sync @@ -46,6 +46,7 @@ test_begin_subtest "notmuch show works with renamed file (without notmuch new)" output=$(notmuch show --format=json id:${gen_msg_id} | filter_show_json) test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite", "match": true, +"excluded": false, "filename": "MAIL_DIR/cur/adding-replied-tag:2,RS", "timestamp": 978709437, "date_relative": "2001-01-05", @@ -53,8 +54,6 @@ test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite", "headers": {"Subject": "Adding replied tag", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notmuchmail.org>", -"Cc": "", -"Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, diff --git a/test/multipart b/test/multipart index 2dd73f59..72d39276 100755 --- a/test/multipart +++ b/test/multipart @@ -46,6 +46,7 @@ Content-Disposition: inline EOF cat embedded_message >> ${MAIL_DIR}/multipart cat <<EOF >> ${MAIL_DIR}/multipart + --=-=-= Content-Disposition: attachment; filename=attachment @@ -108,7 +109,7 @@ notmuch new > /dev/null test_begin_subtest "--format=text --part=0, full message" notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <<EOF >EXPECTED -message{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart +message{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_DIR}/multipart header{ Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread) Subject: Multipart message @@ -322,10 +323,10 @@ notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | s echo >>OUTPUT # expect *no* newline at end of output cat <<EOF >EXPECTED -{"id": "87liy5ap00.fsf@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@cworth.org>", "To": "cworth@cworth.org", "Cc": "", "Bcc": "", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [ +{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "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@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, @@ -342,7 +343,7 @@ cat <<EOF >EXPECTED {"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@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, @@ -358,7 +359,7 @@ echo >>OUTPUT # expect *no* newline at end of output cat <<EOF >EXPECTED {"id": 2, "content-type": "multipart/mixed", "content": [ -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, @@ -372,7 +373,7 @@ notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | s echo >>OUTPUT # expect *no* newline at end of output cat <<EOF >EXPECTED -{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [ {"id": 4, "content-type": "multipart/alternative", "content": [ {"id": 5, "content-type": "text/html"}, {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]} @@ -449,58 +450,80 @@ test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart test_begin_subtest "--format=raw --part=1, message body" notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT -# output should *not* include newline -echo >>OUTPUT -cat <<EOF >EXPECTED -Subject: html message -From: Carl Worth <cworth@cworth.org> -To: cworth@cworth.org -Date: Fri, 05 Jan 2001 15:42:57 +0000 - -<p>This is an embedded message, with a multipart/alternative part.</p> -This is an embedded message, with a multipart/alternative part. -This is a text attachment. -And this message is signed. - --Carl ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.11 (GNU/Linux) - -iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD -W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE -=zkga ------END PGP SIGNATURE----- -EOF -test_expect_equal_file OUTPUT EXPECTED +test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart test_begin_subtest "--format=raw --part=2, multipart/mixed" notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <<EOF >EXPECTED -Subject: html message +Content-Type: multipart/mixed; boundary="=-=-=" + +--=-=-= +Content-Type: message/rfc822 +Content-Disposition: inline + From: Carl Worth <cworth@cworth.org> To: cworth@cworth.org +Subject: html message Date: Fri, 05 Jan 2001 15:42:57 +0000 +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) +Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org> +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="==-=-==" + +--==-=-== +Content-Type: text/html <p>This is an embedded message, with a multipart/alternative part.</p> + +--==-=-== +Content-Type: text/plain + This is an embedded message, with a multipart/alternative part. + +--==-=-==-- + +--=-=-= +Content-Disposition: attachment; filename=attachment + This is a text attachment. + +--=-=-= + And this message is signed. -Carl + +--=-=-=-- EOF test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "--format=raw --part=3, rfc822 part" -test_subtest_known_broken - notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT test_expect_equal_file OUTPUT embedded_message -test_begin_subtest "--format=raw --part=4, rfc822's html part" +test_begin_subtest "--format=raw --part=4, rfc822's multipart" notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT cat <<EOF >EXPECTED +From: Carl Worth <cworth@cworth.org> +To: cworth@cworth.org +Subject: html message +Date: Fri, 05 Jan 2001 15:42:57 +0000 +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) +Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org> +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="==-=-==" + +--==-=-== +Content-Type: text/html + <p>This is an embedded message, with a multipart/alternative part.</p> + +--==-=-== +Content-Type: text/plain + This is an embedded message, with a multipart/alternative part. + +--==-=-==-- EOF test_expect_equal_file OUTPUT EXPECTED @@ -589,9 +612,61 @@ Non-text part: text/html EOF test_expect_equal_file OUTPUT EXPECTED +test_begin_subtest "'notmuch reply' to a multipart message with json format" +notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT +cat <<EOF >EXPECTED +{"reply-headers": {"Subject": "Re: Multipart message", + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", + "To": "Carl Worth <cworth@cworth.org>, + cworth@cworth.org", + "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>", + "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"}, + "original": {"id": "XXXXX", + "match": false, + "excluded": false, + "filename": "YYYYY", + "timestamp": 978709437, + "date_relative": "2001-01-05", + "tags": ["attachment","inbox","signed","unread"], + "headers": {"Subject": "Multipart message", + "From": "Carl Worth <cworth@cworth.org>", + "To": "cworth@cworth.org", + "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": {"Subject": "html message", + "From": "Carl Worth <cworth@cworth.org>", + "To": "cworth@cworth.org", + "Date": "Fri, + 05 Jan 2001 15:42:57 +0000"}, + "body": [{"id": 4, + "content-type": "multipart/alternative", + "content": [{"id": 5, + "content-type": "text/html"}, + {"id": 6, + "content-type": "text/plain", + "content": "This is an embedded message, + with a multipart/alternative part.\n"}]}]}]}, + {"id": 7, + "content-type": "text/plain", + "filename": "YYYYY", + "content": "This is a text attachment.\n"}, + {"id": 8, + "content-type": "text/plain", + "content": "And this message is signed.\n\n-Carl\n"}]}, + {"id": 9, + "content-type": "application/pgp-signature"}]}]}} +EOF +test_expect_equal_file OUTPUT EXPECTED + test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair" 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 +test_done
\ No newline at end of file diff --git a/test/notmuch-test b/test/notmuch-test index e14d34e4..bfad5d3c 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -19,6 +19,7 @@ cd $(dirname "$0") TESTS=" basic help-test + config new count search @@ -27,6 +28,7 @@ TESTS=" search-position-overlap-bug search-insufficient-from-quoting search-limiting + excludes tagging json multipart @@ -54,6 +56,7 @@ TESTS=" argument-parsing emacs-test-functions emacs-address-cleaning + emacs-hello emacs-show " TESTS=${NOTMUCH_TESTS:=$TESTS} diff --git a/test/python b/test/python index 6018c2d0..3f03a2e3 100755 --- a/test/python +++ b/test/python @@ -28,4 +28,12 @@ EOF notmuch search --sort=oldest-first --output=messages tag:inbox | sed s/^id:// > EXPECTED test_expect_equal_file OUTPUT EXPECTED +test_begin_subtest "get non-existent file" +test_python <<EOF +import notmuch +db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY) +print db.find_message_by_filename("i-dont-exist") +EOF +test_expect_equal "$(cat OUTPUT)" "None" + test_done @@ -3,11 +3,8 @@ test_description='notmuch show --format=raw' . ./test-lib.sh -test_begin_subtest "Generate some messages" -generate_message -generate_message -output=$(NOTMUCH_NEW) -test_expect_equal "$output" "Added 2 new messages to the database." +add_message +add_message test_begin_subtest "Attempt to show multiple raw messages" output=$(notmuch show --format=raw "*" 2>&1) diff --git a/test/search b/test/search index 414be356..a7a0b18d 100755 --- a/test/search +++ b/test/search @@ -129,29 +129,4 @@ add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12 output=$(notmuch search "bödý" | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)" -test_begin_subtest "Exclude \"deleted\" messages from search" -notmuch config set search.exclude_tags = deleted -generate_message '[subject]="Not deleted"' -generate_message '[subject]="Deleted"' -notmuch new > /dev/null -notmuch tag +deleted id:$gen_msg_id -output=$(notmuch search subject:deleted | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread)" - -test_begin_subtest "Exclude \"deleted\" messages from search, overridden" -output=$(notmuch search subject:deleted and tag:deleted | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Deleted (deleted inbox unread)" - -test_begin_subtest "Exclude \"deleted\" messages from threads" -add_message '[subject]="Not deleted reply"' '[in-reply-to]="<$gen_msg_id>"' -output=$(notmuch search subject:deleted | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) -thread:XXX 2001-01-05 [1/2] Notmuch Test Suite; Not deleted reply (deleted inbox unread)" - -test_begin_subtest "Don't exclude \"deleted\" messages from search if not configured" -notmuch config set search.exclude_tags -output=$(notmuch search subject:deleted | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Not deleted (inbox unread) -thread:XXX 2001-01-05 [2/2] Notmuch Test Suite; Deleted (deleted inbox unread)" - test_done diff --git a/test/search-folder-coherence b/test/search-folder-coherence index f8119cbb..3f6ec763 100755 --- a/test/search-folder-coherence +++ b/test/search-folder-coherence @@ -32,7 +32,7 @@ test_expect_equal_file OUTPUT EXPECTED test_begin_subtest "Test matches folder:spam" output=$(notmuch search folder:spam) -test_expect_equal "$output" "thread:0000000000000001 2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)" +test_expect_equal "$output" "thread:0000000000000001 2001-01-05 [1/1] Notmuch Test Suite; Single new message (inbox unread)" test_begin_subtest "Remove folder:spam copy of email" rm $dir/spam/$(basename $file_x) diff --git a/test/symbol-test.cc b/test/symbol-test.cc index 1548ca40..3e96c034 100644 --- a/test/symbol-test.cc +++ b/test/symbol-test.cc @@ -4,7 +4,8 @@ int main() { - (void) notmuch_database_open("fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY); + notmuch_database_t *notmuch; + notmuch_database_open("fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much); try { (void) new Xapian::WritableDatabase("./nonexistant", Xapian::DB_OPEN); diff --git a/test/tagging b/test/tagging index 77202bf9..e4782ed4 100755 --- a/test/tagging +++ b/test/tagging @@ -38,4 +38,12 @@ test_expect_equal "$output" "\ thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 unread) thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)" +test_begin_subtest "Tagging order" +notmuch tag +tag4 -tag4 One +notmuch tag -tag4 +tag4 Two +output=$(notmuch search \* | notmuch_search_sanitize) +test_expect_equal "$output" "\ +thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 unread) +thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)" + test_done diff --git a/test/test-lib.sh b/test/test-lib.sh index 27815067..06aaea27 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -318,7 +318,11 @@ generate_message () fi if [ -z "${template[subject]}" ]; then - template[subject]="Test message #${gen_msg_cnt}" + if [ -n "$test_subtest_name" ]; then + template[subject]="$test_subtest_name" + else + template[subject]="Test message #${gen_msg_cnt}" + fi fi if [ -z "${template[date]}" ]; then diff --git a/test/thread-naming b/test/thread-naming index 942e5939..1a1a48f6 100755 --- a/test/thread-naming +++ b/test/thread-naming @@ -65,7 +65,7 @@ test_expect_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; t test_begin_subtest 'Test order of messages in "notmuch show"' output=$(notmuch show thread-naming | notmuch_show_sanitize) -test_expect_equal "$output" "message{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first) +test_expect_equal "$output" "message{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $first) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread) Subject: thread-naming: Initial thread subject @@ -79,7 +79,7 @@ This is just a test message (#$first) part} body} message} -message{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1))) +message{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1))) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread) Subject: thread-naming: Older changed subject @@ -93,7 +93,7 @@ This is just a test message (#$((first + 1))) part} body} message} -message{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2))) +message{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2))) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread) Subject: thread-naming: Newer changed subject @@ -107,7 +107,7 @@ This is just a test message (#$((first + 2))) part} body} message} -message{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3))) +message{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3))) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread) Subject: thread-naming: Final thread subject @@ -121,7 +121,7 @@ This is just a test message (#$((first + 3))) part} body} message} -message{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4))) +message{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4))) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread) Subject: Re: thread-naming: Initial thread subject @@ -135,7 +135,7 @@ This is just a test message (#$((first + 4))) part} body} message} -message{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5))) +message{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5))) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread) Subject: Aw: thread-naming: Initial thread subject @@ -149,7 +149,7 @@ This is just a test message (#$((first + 5))) part} body} message} -message{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6))) +message{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6))) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread) Subject: Vs: thread-naming: Initial thread subject @@ -163,7 +163,7 @@ This is just a test message (#$((first + 6))) part} body} message} -message{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7))) +message{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7))) header{ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread) Subject: Sv: thread-naming: Initial thread subject |
