unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 2/2] test: use subtest name for generated message subject by default
Date: Sat, 10 Mar 2012 05:24:51 +0400	[thread overview]
Message-ID: <1331342691-26899-3-git-send-email-dmitry.kurochkin@gmail.com> (raw)
In-Reply-To: <1331342691-26899-1-git-send-email-dmitry.kurochkin@gmail.com>

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                |    2 +-
 test/search-folder-coherence |    2 +-
 test/test-lib.sh             |    6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/encoding b/test/encoding
index 98abf77..2e1326e 100755
--- a/test/encoding
+++ b/test/encoding
@@ -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
diff --git a/test/search-folder-coherence b/test/search-folder-coherence
index f8119cb..3f6ec76 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/test-lib.sh b/test/test-lib.sh
index 2781506..06aaea2 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
-- 
1.7.9.1

  parent reply	other threads:[~2012-03-10  1:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 22:06 [PATCH 1/2] test: remove "Generate some messages" test from raw Dmitry Kurochkin
2012-01-30 22:06 ` [PATCH 2/2] test: use subtest name for generated message subject by default Dmitry Kurochkin
2012-03-09  8:24   ` Jani Nikula
2012-02-15 18:33 ` [PATCH 1/2] test: remove "Generate some messages" test from raw Dmitry Kurochkin
2012-03-01 23:09   ` Dmitry Kurochkin
2012-03-10  1:24 ` [PATCH v2 0/2] test: use subtest name for generated message subject Dmitry Kurochkin
2012-03-10  1:24   ` [PATCH v2 1/2] test: remove "Generate some messages" test from raw Dmitry Kurochkin
2012-03-10  1:24   ` Dmitry Kurochkin [this message]
2012-03-18 12:50   ` [PATCH v2 0/2] test: use subtest name for generated message subject David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331342691-26899-3-git-send-email-dmitry.kurochkin@gmail.com \
    --to=dmitry.kurochkin@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).