[PATCH 2/2] test: use subtest name for generated message subject by default
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Mon, 30 Jan 2012 22:06:35 +0000 (02:06 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:44 +0000 (09:43 -0800)
02/b0c51e9a4866898f4f71ba4c3e940477300fdc [new file with mode: 0644]

diff --git a/02/b0c51e9a4866898f4f71ba4c3e940477300fdc b/02/b0c51e9a4866898f4f71ba4c3e940477300fdc
new file mode 100644 (file)
index 0000000..06590c0
--- /dev/null
@@ -0,0 +1,138 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7E8F1431E64\r
+       for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 14:07:50 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id PCoEc-+497Xx for <notmuch@notmuchmail.org>;\r
+       Mon, 30 Jan 2012 14:07:49 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A8AA4431FBC\r
+       for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 14:07:49 -0800 (PST)\r
+Received: by mail-bk0-f53.google.com with SMTP id 11so1911694bke.26\r
+       for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 14:07:49 -0800 (PST)\r
+Received-SPF: pass (google.com: domain of dmitry.kurochkin@gmail.com\r
+       designates 10.204.152.145 as permitted sender)\r
+       client-ip=10.204.152.145; \r
+Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
+       dmitry.kurochkin@gmail.com designates 10.204.152.145 as\r
+       permitted sender) smtp.mail=dmitry.kurochkin@gmail.com;\r
+       dkim=pass header.i=dmitry.kurochkin@gmail.com\r
+Received: from mr.google.com ([10.204.152.145])\r
+       by 10.204.152.145 with SMTP id g17mr10538015bkw.97.1327961269409\r
+       (num_hops = 1); Mon, 30 Jan 2012 14:07:49 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=hwQzn4cLgMkdVaVefZITkYqmq0w/TNq/tgJVYEwf/3Y=;\r
+       b=HYi+6KQyXIaY3X2trHAuEyGWg7yJHyZ0ykAtkFDQ5yxVkEpWbLqUmjDWBL16YmH0Vo\r
+       y6eiPmJ+hgMxMbtlboMdwXfZM8rHVbSAN1a6o08VBmnz1xId3BcZk7pXSAEyzNgXJZmU\r
+       AqbO962HCpxOtaBjQqZELMJ4AFDtYEOgPUw4M=\r
+Received: by 10.204.152.145 with SMTP id g17mr9149983bkw.97.1327961269326;\r
+       Mon, 30 Jan 2012 14:07:49 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id ez5sm40482935bkc.15.2012.01.30.14.07.48\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 30 Jan 2012 14:07:48 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] test: use subtest name for generated message subject by\r
+       default\r
+Date: Tue, 31 Jan 2012 02:06:35 +0400\r
+Message-Id: <1327961195-4204-2-git-send-email-dmitry.kurochkin@gmail.com>\r
+X-Mailer: git-send-email 1.7.8.3\r
+In-Reply-To: <1327961195-4204-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+References: <1327961195-4204-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 30 Jan 2012 22:07:50 -0000\r
+\r
+Before the change, messages generated by generate_message() used "Test\r
+message #N" for default subject where N is the generated messages\r
+counter.  Since message subject is commonly present in expected\r
+results, there is a chance of breaking other tests when a new\r
+generate_message() call is added.  The patch changes default subject\r
+value for generated messages to subtest name if it is available.  If\r
+subtest name is not available (i.e. message is generated during test\r
+initialization), the old default value is used (in this case it is\r
+fine to have the counter in the subject).\r
+\r
+Another benefit of this change is a sane default value for subject in\r
+generated messages, which would allow to simplify code like:\r
+\r
+  test_begin_subtest "test for a cool feature"\r
+  add_message [subject]="message for test for a cool feature"\r
+---\r
+ test/encoding                |    2 +-\r
+ test/search-folder-coherence |    2 +-\r
+ test/test-lib.sh             |    6 +++++-\r
+ 3 files changed, 7 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/test/encoding b/test/encoding\r
+index 33259c1..dbaceb0 100755\r
+--- a/test/encoding\r
++++ b/test/encoding\r
+@@ -9,7 +9,7 @@ output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)\r
+ test_expect_equal "$output" "\f\r
+message{ id:msg-001@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-001\r
\f\r
+header{\r
+ Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox unread)\r
+-Subject: Test message #1\r
++Subject: Message with text of unknown charset\r
+ From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+ To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+ Date: Fri, 05 Jan 2001 15:43:57 +0000\r
+diff --git a/test/search-folder-coherence b/test/search-folder-coherence\r
+index f8119cb..3f6ec76 100755\r
+--- a/test/search-folder-coherence\r
++++ b/test/search-folder-coherence\r
+@@ -32,7 +32,7 @@ test_expect_equal_file OUTPUT EXPECTED\r
\r
+ test_begin_subtest "Test matches folder:spam"\r
+ output=$(notmuch search folder:spam)\r
+-test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"\r
++test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Single new message (inbox unread)"\r
\r
+ test_begin_subtest "Remove folder:spam copy of email"\r
+ rm $dir/spam/$(basename $file_x)\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 8158328..94efdc1 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -318,7 +318,11 @@ generate_message ()\r
+     fi\r
\r
+     if [ -z "${template[subject]}" ]; then\r
+-      template[subject]="Test message #${gen_msg_cnt}"\r
++      if [ -n "$test_subtest_name" ]; then\r
++          template[subject]="$test_subtest_name"\r
++      else\r
++          template[subject]="Test message #${gen_msg_cnt}"\r
++      fi\r
+     fi\r
\r
+     if [ -z "${template[date]}" ]; then\r
+-- \r
+1.7.8.3\r
+\r