[PATCH] test: optionally print subtest number
authorDavid Bremner <david@tethera.net>
Tue, 13 Dec 2011 19:56:47 +0000 (15:56 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:49 +0000 (09:40 -0800)
dc/07efcbfd9c970c0cebf6a34caaff83eb9fb002 [new file with mode: 0644]

diff --git a/dc/07efcbfd9c970c0cebf6a34caaff83eb9fb002 b/dc/07efcbfd9c970c0cebf6a34caaff83eb9fb002
new file mode 100644 (file)
index 0000000..c9a5c61
--- /dev/null
@@ -0,0 +1,104 @@
+Return-Path: <bremner@pivot.cs.unb.ca>\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 CD991429E27\r
+       for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 11:57:22 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] 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 1UnhDM69u5ah for <notmuch@notmuchmail.org>;\r
+       Tue, 13 Dec 2011 11:57:21 -0800 (PST)\r
+Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id EB6D4429E26\r
+       for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 11:57:20 -0800 (PST)\r
+Received: from convex-new.cs.unb.ca ([131.202.13.154])\r
+       by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pBDJunAr029926;\r
+       Tue, 13 Dec 2011 15:56:51 -0400\r
+Received: from bremner by convex-new.cs.unb.ca with local (Exim 4.72)\r
+       (envelope-from <bremner@pivot.cs.unb.ca>)\r
+       id 1RaYT3-0008JG-A6; Tue, 13 Dec 2011 15:56:49 -0400\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: optionally print subtest number\r
+Date: Tue, 13 Dec 2011 15:56:47 -0400\r
+Message-Id: <1323806207-31888-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.7.5.4\r
+Cc: David Bremner <bremner@debian.org>\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: Tue, 13 Dec 2011 19:57:22 -0000\r
+\r
+From: David Bremner <bremner@debian.org>\r
+\r
+The idea is that $test_count could be used in tests to label\r
+intermediate files. The output enabled by this patch (and --debug)\r
+helps figure out which OUTPUT.nn file belongs to which test in case\r
+several subtests write to OUTPUT.$test_count\r
+---\r
+\r
+Is there something that depends on the test format? I find it pretty\r
+handy to have the subtest numbers, but I don't want to break some\r
+other tools. I followed the existing style of conditionally defining\r
+functions, but maybe someone with more bash-fu can improve that.\r
+\r
+ test/test-lib.sh |   12 ++++++++++++\r
+ 1 files changed, 12 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 6be93fe..aaaaf5c 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -116,6 +116,16 @@ do\r
+       esac\r
+ done\r
\r
++if test -n "$debug"; then\r
++    print_subtest () {\r
++      printf "\t[%d]\t" $(($test_count - 1))\r
++    }\r
++else\r
++    print_subtest () {\r
++      true\r
++    }\r
++fi\r
++\r
+ if test -n "$color"; then\r
+       say_color () {\r
+               (\r
+@@ -132,6 +142,7 @@ if test -n "$color"; then\r
+               printf " "\r
+                 printf "$@"\r
+               tput sgr0\r
++              print_subtest\r
+               )\r
+       }\r
+ else\r
+@@ -140,6 +151,7 @@ else\r
+               shift\r
+               printf " "\r
+                 printf "$@"\r
++              print_subtest\r
+       }\r
+ fi\r
\r
+-- \r
+1.7.5.4\r
+\r