From e0e9b4d4aaab7b33c695bdc302bf1b7f7c21ddb1 Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Sat, 10 Mar 2012 05:24:51 +0400 Subject: [PATCH] [PATCH v2 2/2] test: use subtest name for generated message subject by default --- e1/f6cc31eb9fa5a0c7a58d40d25009ace5a480e0 | 132 ++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 e1/f6cc31eb9fa5a0c7a58d40d25009ace5a480e0 diff --git a/e1/f6cc31eb9fa5a0c7a58d40d25009ace5a480e0 b/e1/f6cc31eb9fa5a0c7a58d40d25009ace5a480e0 new file mode 100644 index 000000000..e15e821f3 --- /dev/null +++ b/e1/f6cc31eb9fa5a0c7a58d40d25009ace5a480e0 @@ -0,0 +1,132 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 6D4D3431FD9 + for ; Fri, 9 Mar 2012 17:26:38 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id z3WO3esHAl1z for ; + Fri, 9 Mar 2012 17:26:37 -0800 (PST) +Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com + [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 20D4D431FD7 + for ; Fri, 9 Mar 2012 17:26:32 -0800 (PST) +Received: by mail-bk0-f53.google.com with SMTP id j4so1791432bkw.26 + for ; Fri, 09 Mar 2012 17:26:32 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; + bh=69I5G/MErbP0QaXBeDuxYnwhz5PPnw/eOdijPROGiBU=; + b=ioMMgPQBGqePllMisBE9f2jW6bM6+AOz2CvNLXM8lRgySLhnB7lbEIkd+bFevZ2KDj + 0LBXPGzpNf05Ghk6LLX4dP9pr7wfLxAxq18Hosei+mtuU5CDbz+BR2CRaFUYtGUuODdR + xxDP/CvPtGpb5uKrIlmVysfoXQ1eFZ4GZdH/tis3YUhVyoyMwXmWJ8bbZUEl+kAcwGq+ + sFVOtPrz4MIzA0gHXMZb/UQ2Q4OdKLaVRNPN09x+asIG1/0xXksCbvbJ7sCTZFraBuOe + I0GOvOmx8v9tO3xXrcDW9sC9F/ZMv9yMuHFEjHJ8w/RjVBvYM9nXlI0U7KX5YeZKrKLI + ojxg== +Received: by 10.204.129.13 with SMTP id m13mr1771210bks.119.1331342792652; + Fri, 09 Mar 2012 17:26:32 -0800 (PST) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id f5sm12030927bke.9.2012.03.09.17.26.31 + (version=TLSv1/SSLv3 cipher=OTHER); + Fri, 09 Mar 2012 17:26:32 -0800 (PST) +From: Dmitry Kurochkin +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 +Message-Id: <1331342691-26899-3-git-send-email-dmitry.kurochkin@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1331342691-26899-1-git-send-email-dmitry.kurochkin@gmail.com> +References: <1327961195-4204-1-git-send-email-dmitry.kurochkin@gmail.com> + <1331342691-26899-1-git-send-email-dmitry.kurochkin@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 10 Mar 2012 01:26:39 -0000 + +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" " +message{ id:msg-001@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-001 + +header{ + Notmuch Test Suite (2001-01-05) (inbox unread) +-Subject: Test message #1 ++Subject: Message with text of unknown charset + From: Notmuch Test Suite + To: Notmuch Test Suite + 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 + -- 2.26.2