X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2FT310-emacs.sh;h=a05b828ae9f759f31c12a41c015cc77224d8a4ea;hp=cb9e99a58f7d1ded2740f5c8d28af85d13f54ba6;hb=2786aa4d548d28579c761e9358d44c84dfb29068;hpb=71eaa19350883b30bafe885ea083c2e3f1621e10 diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh index cb9e99a5..a05b828a 100755 --- a/test/T310-emacs.sh +++ b/test/T310-emacs.sh @@ -2,9 +2,11 @@ test_description="emacs interface" . $(dirname "$0")/test-lib.sh || exit 1 +. $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output +test_require_emacs add_email_corpus # syntax errors in test-lib.el cause mysterious failures @@ -39,13 +41,29 @@ test_emacs '(notmuch-search "tag:inbox") (test-output)' test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT +test_begin_subtest "Functions in search-result-format" +test_emacs '(let + ((notmuch-search-result-format + (quote ((notmuch-test-result-flags . "%s ") + ("date" . "%12s ") + ("count" . "%9s ") + ("authors" . "%-30s ") + ("subject" . "%s ") + ("tags" . "(%s)"))))) + (notmuch-search "tag:inbox") + (notmuch-test-wait) + (test-output))' +test_expect_equal_file $EXPECTED/search-result-format-function OUTPUT + test_begin_subtest "Incremental parsing of search results" -test_emacs "(ad-enable-advice 'notmuch-search-process-filter 'around 'pessimal) - (ad-activate 'notmuch-search-process-filter) - (notmuch-search \"tag:inbox\") - (notmuch-test-wait) - (ad-disable-advice 'notmuch-search-process-filter 'around 'pessimal) - (ad-activate 'notmuch-search-process-filter) +test_emacs "(cl-letf* (((symbol-function 'orig) + (symbol-function 'notmuch-search-process-filter)) + ((symbol-function 'notmuch-search-process-filter) + (lambda (proc string) + (cl-loop for char across string + do (orig proc (char-to-string char)))))) + (notmuch-search \"tag:inbox\") + (notmuch-test-wait)) (test-output)" test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT @@ -86,14 +104,13 @@ test_emacs "(let ((notmuch-show-indent-messages-width 4)) test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation OUTPUT test_begin_subtest "notmuch-show for message with invalid From" -test_subtest_broken_gmime_3 add_message "[subject]=\"message-with-invalid-from\"" \ "[from]=\"\\\"Invalid \\\" From\\\" \"" thread=$(notmuch search --output=threads subject:message-with-invalid-from) test_emacs "(notmuch-show \"$thread\") (test-output \"OUTPUT.raw\")" cat <EXPECTED -"Invalid " (2001-01-05) (inbox) +Invalid " From (2001-01-05) (inbox) Subject: message-with-invalid-from To: Notmuch Test Suite Date: GENERATED_DATE @@ -160,6 +177,28 @@ test_emacs "(notmuch-show \"$os_x_darwin_thread\") output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)" +test_begin_subtest "notmuch-show: before-tag-hook is run, variables are defined" +output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil) + (notmuch-before-tag-hook (function notmuch-test-tag-hook))) + (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com") + (execute-kbd-macro "+activate-hook\n") + (execute-kbd-macro "-activate-hook\n") + notmuch-test-tag-hook-output)') +test_expect_equal "$output" \ +'(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook") + ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))' + +test_begin_subtest "notmuch-show: after-tag-hook is run, variables are defined" +output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil) + (notmuch-after-tag-hook (function notmuch-test-tag-hook))) + (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com") + (execute-kbd-macro "+activate-hook\n") + (execute-kbd-macro "-activate-hook\n") + notmuch-test-tag-hook-output)') +test_expect_equal "$output" \ +'(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook") + ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))' + test_begin_subtest "Message with .. in Message-Id:" add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"' test_emacs '(notmuch-search "id:\"123..456@example\"") @@ -446,6 +485,31 @@ Sender writes: EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "Reply with show.extra_headers set" +notmuch config set show.extra_headers Received +add_message '[from]="Sender "' \ + [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))" +cat <EXPECTED +From: Notmuch Test Suite +To: Sender +Subject: Re: ${test_subtest_name} +In-Reply-To: <${gen_msg_id}> +Fcc: ${MAIL_DIR}/sent +References: <${gen_msg_id}> +--text follows this line-- +Sender writes: + +> This is just a test message (#${gen_msg_cnt}) +EOF +notmuch config set show.extra_headers +test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "Reply from address in named group list within emacs" add_message '[from]="Sender "' \ '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \ @@ -641,7 +705,7 @@ References: --text follows this line-- test_suite@notmuchmail.org writes: -> This is just a test message (#7) +> This is just a test message (#${gen_msg_cnt}) EOF test_expect_equal_file EXPECTED OUTPUT @@ -844,7 +908,7 @@ test_emacs '(notmuch-show "id:\"bought\"") (notmuch-show-stash-message-id-stripped) (notmuch-show-stash-tags) (notmuch-show-stash-filename) - (notmuch-show-stash-mlarchive-link "Gmane") + (notmuch-show-stash-mlarchive-link "Notmuch") (notmuch-show-stash-mlarchive-link "MARC") (notmuch-show-stash-mlarchive-link "Mail Archive, The") (switch-to-buffer @@ -865,7 +929,7 @@ id:bought bought inbox,stashtest ${gen_msg_filename} -https://mid.gmane.org/bought +https://nmbug.notmuchmail.org/nmweb/show/bought https://marc.info/?i=bought https://mid.mail-archive.com/bought EOF @@ -1034,9 +1098,8 @@ End of search results. === MESSAGES === YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details) === ERROR === -[XXX] YYY/notmuch_fail exited with status 1 -command: YYY/notmuch_fail search --format\=sexp --format-version\=4 --sort\=newest-first tag\:inbox +command: YYY/notmuch_fail search --format\=sexp --format-version\=5 --sort\=newest-first tag\:inbox exit status: 1" test_begin_subtest "Search handles subprocess warnings" @@ -1130,4 +1193,10 @@ This text added by the hook. EOF test_expect_equal_file EXPECTED OUTPUT +test_begin_subtest "notmuch-search with nonexistent CWD" +test_emacs '(test-log-error + (let ((default-directory "/nonexistent")) + (notmuch-search "*")))' +test_expect_equal "$(cat MESSAGES)" "COMPLETE" + test_done