By default, emacs hides the User-Agent and References headers when
composing mail. This is a good thing for users, but a bad thing for
testing, since we can create ugly or invalid headers and not have it
show up in the tests.

By setting message-hidden-headers to an empty list, we force emacs to
show all the headers, so we can check that they're correct. Users
won't see this, but it will let us catch future bugs.

As a side-effect, this breaks all the reply tests, since there is a
bug with the References and User-Agent headers, fixed in the next commit.
---
 test/emacs |   55 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/test/emacs b/test/emacs
index 30654bb..15cc778 100755
--- a/test/emacs
+++ b/test/emacs
@@ -267,17 +267,23 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Reply within emacs"
-test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
+test_subtest_known_broken
+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 <[email protected]>
 To: [email protected]
 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--
 Notmuch Test Suite <[email protected]> writes:
 
@@ -286,19 +292,24 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Reply from alternate address within emacs"
+test_subtest_known_broken
 add_message '[from]="Sender <[email protected]>"' \
             [to][email protected]
 
-test_emacs "(notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
+test_emacs "(let ((message-hidden-headers '()))
+           (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
            (notmuch-test-wait)
            (notmuch-search-reply-to-thread)
-           (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 <[email protected]>
 To: Sender <[email protected]>
 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 <[email protected]> writes:
 
@@ -307,20 +318,25 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Reply from address in named group list within emacs"
+test_subtest_known_broken
 add_message '[from]="Sender <[email protected]>"' \
             '[to]=group:[email protected],[email protected]\;' \
              [cc][email protected]
 
-test_emacs "(notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
+test_emacs "(let ((message-hidden-headers '()))
+           (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
            (notmuch-test-wait)
            (notmuch-search-reply-to-thread)
-           (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 <[email protected]>
 To: Sender <[email protected]>, [email protected]
 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 <[email protected]> writes:
 
@@ -329,15 +345,20 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Reply within emacs to a multipart/mixed message"
-test_emacs '(notmuch-show "id:20091118002059.067214ed@hikari")
+test_subtest_known_broken
+test_emacs '(let ((message-hidden-headers ''()))
+           (notmuch-show "id:20091118002059.067214ed@hikari")
                (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 <[email protected]>
 To: Adrian Perez de Castro <[email protected]>, [email protected]
 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 <[email protected]> writes:
 
@@ -388,15 +409,20 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Reply within emacs to a multipart/alternative message"
-test_emacs '(notmuch-show 
"id:[email protected]")
+test_subtest_known_broken
+test_emacs '(let ((message-hidden-headers ''()))
+           (notmuch-show 
"id:[email protected]")
                (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 <[email protected]>
 To: Alex Botero-Lowry <[email protected]>, [email protected]
 Subject: Re: [notmuch] preliminary FreeBSD support
 In-Reply-To: <[email protected]>
 Fcc: ${MAIL_DIR}/sent
+References: <[email protected]>
+User-Agent: Notmuch/XXX Emacs/XXX
 --text follows this line--
 Alex Botero-Lowry <[email protected]> writes:
 
@@ -424,19 +450,24 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Quote MML tags in reply"
+test_subtest_known_broken
 message_id='[email protected]'
 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 <[email protected]>
 To: 
 Subject: Re: Quote MML tags in reply
 In-Reply-To: <[email protected]>
 Fcc: ${MAIL_DIR}/sent
+References: <[email protected]>
+User-Agent: Notmuch/XXX Emacs/XXX
 --text follows this line--
 Notmuch Test Suite <[email protected]> writes:
 
-- 
1.7.5.4

_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to