]> git.notmuchmail.org Git - notmuch/commitdiff
test: use subtest name for generated message subject by default
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Sat, 10 Mar 2012 01:24:51 +0000 (05:24 +0400)
committerDavid Bremner <bremner@debian.org>
Sun, 18 Mar 2012 12:14:22 +0000 (09:14 -0300)
Before the change, messages generated by generate_message() used "Test
message #N" for default subject where N is the generated messages
counter.  Since message subject is commonly present in expected
results, there is a chance of breaking other tests when a new
generate_message() call is added.  The patch changes default subject
value for generated messages to subtest name if it is available.  If
subtest name is not available (i.e. message is generated during test
initialization), the old default value is used (in this case it is
fine to have the counter in the subject).

Another benefit of this change is a sane default value for subject in
generated messages, which would allow to simplify code like:

  test_begin_subtest "test for a cool feature"
  add_message [subject]="message for test for a cool feature"

test/encoding
test/search-folder-coherence
test/test-lib.sh

index 98abf77f76ff15796a46b122f5c988dc9a0f08da..2e1326ebe1bca735c461704d8147dd180a1a3aa9 100755 (executable)
@@ -9,7 +9,7 @@ output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
 test_expect_equal "$output" "\fmessage{ id:msg-001@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-001
 \fheader{
 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
index f8119cbb4d99be909045e1ddfab500e6813c1940..3f6ec76348c07de88d99def9003475083fa05f5e 100755 (executable)
@@ -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)
index 278150677c4a92e8df4a723be693fae108213576..06aaea270e946cb6811ed6e18258781b5d267b8d 100644 (file)
@@ -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