[PATCH v2 03/10] test: add test state reset to test_expect_* functions that did not...
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Thu, 17 Nov 2011 13:05:56 +0000 (17:05 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:17 +0000 (09:40 -0800)
fc/709fda3f0b7ba16eea22fabc6da6813e27388c [new file with mode: 0644]

diff --git a/fc/709fda3f0b7ba16eea22fabc6da6813e27388c b/fc/709fda3f0b7ba16eea22fabc6da6813e27388c
new file mode 100644 (file)
index 0000000..498188e
--- /dev/null
@@ -0,0 +1,156 @@
+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 D8B70429E36\r
+       for <notmuch@notmuchmail.org>; Thu, 17 Nov 2011 05:06:35 -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 1oeUwnRjjhFJ for <notmuch@notmuchmail.org>;\r
+       Thu, 17 Nov 2011 05:06:34 -0800 (PST)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-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 BEA4D429E37\r
+       for <notmuch@notmuchmail.org>; Thu, 17 Nov 2011 05:06:31 -0800 (PST)\r
+Received: by mail-bw0-f53.google.com with SMTP id q10so2108356bka.26\r
+       for <notmuch@notmuchmail.org>; Thu, 17 Nov 2011 05:06:31 -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=fQ3NP9/UoQnEjXReAX4S7QA127u2pjlZTGmrqY1lPJk=;\r
+       b=n5kg4e2IsKP04CkwpbKE5AdaYPkSr2/ESxtBDJBtkc1yysh88R8B+D0eIHMpgiHcOf\r
+       3afykFLG9qLiBaEgpaDF+YxyFZRbTgImstYf+W5vOqp+F9CW94ln70bRi87su+jB5eZj\r
+       jx8BDTdApyFjB2selWigeztR67yJUet/9pe1M=\r
+Received: by 10.204.156.150 with SMTP id x22mr33537401bkw.86.1321535191219;\r
+       Thu, 17 Nov 2011 05:06:31 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id j9sm41234411bkd.2.2011.11.17.05.06.29\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 17 Nov 2011 05:06:30 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 03/10] test: add test state reset to test_expect_*\r
+       functions that did not have it\r
+Date: Thu, 17 Nov 2011 17:05:56 +0400\r
+Message-Id: <1321535163-4895-4-git-send-email-dmitry.kurochkin@gmail.com>\r
+X-Mailer: git-send-email 1.7.7.2\r
+In-Reply-To: <1321535163-4895-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+References: <1321535163-4895-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: Thu, 17 Nov 2011 13:06:36 -0000\r
+\r
+---\r
+ test/test-lib.sh |    3 +++\r
+ 1 files changed, 3 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index ff85848..f21e45e 100755\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -622,82 +622,85 @@ test_skip () {\r
+               test_reset_state_\r
+               say_color skip >&3 "skipping test: $@"\r
+               say_color skip "%-6s" "SKIP"\r
+               echo " $1"\r
+               : true\r
+               ;;\r
+       *)\r
+               false\r
+               ;;\r
+       esac\r
+ }\r
\r
+ test_subtest_known_broken () {\r
+       test_subtest_known_broken_=t\r
+ }\r
\r
+ test_expect_success () {\r
+       test "$#" = 3 && { prereq=$1; shift; } || prereq=\r
+       test "$#" = 2 ||\r
+       error "bug in the test script: not 2 or 3 parameters to test-expect-success"\r
++      test_reset_state_\r
+       if ! test_skip "$@"\r
+       then\r
+               test_run_ "$2"\r
+               if [ "$?" = 0 -a "$eval_ret" = 0 ]\r
+               then\r
+                       test_ok_ "$1"\r
+               else\r
+                       test_failure_ "$@"\r
+               fi\r
+       fi\r
+ }\r
\r
+ test_expect_code () {\r
+       test "$#" = 4 && { prereq=$1; shift; } || prereq=\r
+       test "$#" = 3 ||\r
+       error "bug in the test script: not 3 or 4 parameters to test-expect-code"\r
++      test_reset_state_\r
+       if ! test_skip "$@"\r
+       then\r
+               test_run_ "$3"\r
+               if [ "$?" = 0 -a "$eval_ret" = "$1" ]\r
+               then\r
+                       test_ok_ "$2"\r
+               else\r
+                       test_failure_ "$@"\r
+               fi\r
+       fi\r
+ }\r
\r
+ # test_external runs external test scripts that provide continuous\r
+ # test output about their progress, and succeeds/fails on\r
+ # zero/non-zero exit code.  It outputs the test output on stdout even\r
+ # in non-verbose mode, and announces the external script with "* run\r
+ # <n>: ..." before running it.  When providing relative paths, keep in\r
+ # mind that all scripts run in "trash directory".\r
+ # Usage: test_external description command arguments...\r
+ # Example: test_external 'Perl API' perl ../path/to/test.pl\r
+ test_external () {\r
+       test "$#" = 4 && { prereq=$1; shift; } || prereq=\r
+       test "$#" = 3 ||\r
+       error >&5 "bug in the test script: not 3 or 4 parameters to test_external"\r
+       descr="$1"\r
+       shift\r
++      test_reset_state_\r
+       if ! test_skip "$descr" "$@"\r
+       then\r
+               # Announce the script to reduce confusion about the\r
+               # test output that follows.\r
+               say_color "" " run $test_count: $descr ($*)"\r
+               # Run command; redirect its stderr to &4 as in\r
+               # test_run_, but keep its stdout on our stdout even in\r
+               # non-verbose mode.\r
+               "$@" 2>&4\r
+               if [ "$?" = 0 ]\r
+               then\r
+                       test_ok_ "$descr"\r
+               else\r
+                       test_failure_ "$descr" "$@"\r
+               fi\r
+       fi\r
+ }\r
\r
+ # Like test_external, but in addition tests that the command generated\r
+ # no output on stderr.\r
+-- \r
+1.7.7.2\r
+\r