[PATCH] test: Abort driver if a test script aborts
authorAustin Clements <amdragon@MIT.EDU>
Wed, 28 Nov 2012 04:13:16 +0000 (23:13 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:04 +0000 (09:51 -0800)
8e/940f17ed38eb80e9231dc6e9939ea573c1a5f4 [new file with mode: 0644]

diff --git a/8e/940f17ed38eb80e9231dc6e9939ea573c1a5f4 b/8e/940f17ed38eb80e9231dc6e9939ea573c1a5f4
new file mode 100644 (file)
index 0000000..cb6a486
--- /dev/null
@@ -0,0 +1,138 @@
+Return-Path: <amdragon@mit.edu>\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 AFC43431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 27 Nov 2012 20:13:25 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 ncVDXiUMd52V for <notmuch@notmuchmail.org>;\r
+       Tue, 27 Nov 2012 20:13:25 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
+       [18.7.68.35])\r
+       by olra.theworths.org (Postfix) with ESMTP id E7FAF431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 27 Nov 2012 20:13:24 -0800 (PST)\r
+X-AuditID: 12074423-b7f066d000004241-b3-50b58f6374be\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id C9.92.16961.36F85B05; Tue, 27 Nov 2012 23:13:23 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qAS4DMIx020203; \r
+       Tue, 27 Nov 2012 23:13:22 -0500\r
+Received: from drake.dyndns.org\r
+       (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+       [209.6.116.242]) (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAS4DKt4007374\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Tue, 27 Nov 2012 23:13:21 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1TdZ1U-0007af-Ns; Tue, 27 Nov 2012 23:13:20 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: Abort driver if a test script aborts\r
+Date: Tue, 27 Nov 2012 23:13:16 -0500\r
+Message-Id: <1354075997-29140-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsUixG6nopvcvzXA4PN1eYvrN2cyW7xZOY/V\r
+       gcnj8NeFLB7PVt1iDmCK4rJJSc3JLEst0rdL4MqYv12v4IlwRXdPJ1sDY7tAFyMHh4SAiUT/\r
+       JPcuRk4gU0ziwr31bF2MXBxCAvsYJV4daGeBcDYwSuy6togdpEpI4BGTxNHnzhCJuYwSt08u\r
+       YwFJsAloSGzbv5wRxBYRkJbYeXc2K4jNLGAlcfjqJjBbWMBa4urTo2A1LAKqEtufHAazeQUc\r
+       JO7NW8sMcYaiRPezCWwTGHkXMDKsYpRNya3SzU3MzClOTdYtTk7My0st0jXTy80s0UtNKd3E\r
+       CA4LF+UdjH8OKh1iFOBgVOLhfWC+NUCINbGsuDL3EKMkB5OSKO+vXqAQX1J+SmVGYnFGfFFp\r
+       TmrxIUYJDmYlEV6eNqAcb0piZVVqUT5MSpqDRUmc91rKTX8hgfTEktTs1NSC1CKYrAwHh5IE\r
+       794+oEbBotT01Iq0zJwShDQTByfIcB6g4bNAaniLCxJzizPTIfKnGHU5ev91PWEUYsnLz0uV\r
+       EuedDFIkAFKUUZoHNwcWz68YxYHeEuadA1LFA0wFcJNeAS1hAlqSfH0jyJKSRISUVAOjNv+5\r
+       irD81xZJK0KkjrLJ/Fa8L2WfMHO5XFZ/9yT5eYwbFnStsOc7/jBNUCtzwtU2/4dNq9kEWsXW\r
+       RxpGsdn/s6vvYuFSmH/4o4/IqWQDH/Nr25hn3t81pc9kJVffjR2+fjcMzRWziq3tEo54vjqq\r
+       mGJd35Lm8u5WRs2q78d4tv8yLTgwYaUSS3FGoqEWc1FxIgCu0lKWwgIAAA==\r
+Cc: tomi.ollila@iki.fi\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: Wed, 28 Nov 2012 04:13:25 -0000\r
+\r
+Previously, if a test script aborted (e.g., because it passed too few\r
+arguments to a test function), the test driver loop would simply\r
+continue on to the next test script and the final results would\r
+declare that everything passed (except that the test count would look\r
+suspiciously low, but maybe you just misremembered how many tests\r
+there were).\r
+\r
+Now, if a test script exits with a non-zero status and did not produce\r
+a final results file, we propagate that failure out of the driver loop\r
+immediately.\r
+\r
+To keep this simple, this patch removes the PID from the test-results\r
+file name.  This PID was inherited from the git test system and seems\r
+unnecessary, since the file name already includes the name of the test\r
+script and the test-results directory is created anew for each run.\r
+---\r
+ test/basic        |    2 +-\r
+ test/notmuch-test |    6 ++++++\r
+ test/test-lib.sh  |    2 +-\r
+ 3 files changed, 8 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/test/basic b/test/basic\r
+index 1b842d2..b7feb07 100755\r
+--- a/test/basic\r
++++ b/test/basic\r
+@@ -79,7 +79,7 @@ test_begin_subtest "Ensure that -v does not suppress test output"\r
+ output=$(cd $TEST_DIRECTORY; ./test-verbose -v 2>&1 | suppress_diff_date)\r
+ expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date)\r
+ # Do not include the results of test-verbose in totals\r
+-rm $TEST_DIRECTORY/test-results/test-verbose-*\r
++rm $TEST_DIRECTORY/test-results/test-verbose\r
+ rm -r $TEST_DIRECTORY/tmp.test-verbose\r
+ test_expect_equal "$output" "$expected"\r
+ \r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index 9a1b375..f275439 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -81,6 +81,12 @@ trap 'e=$?; kill $!; exit $e' HUP INT TERM\r
+ for test in $TESTS; do\r
+     $TEST_TIMEOUT_CMD ./$test "$@" &\r
+     wait $!\r
++    # If the test failed without producing results, then it aborted,\r
++    # so we should abort, too.\r
++    RES=$?\r
++    if [[ $RES != 0 && ! -e "test-results/${test%.sh}" ]]; then\r
++        exit $RES\r
++    fi\r
+ done\r
+ trap - HUP INT TERM\r
+ \r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index e092231..77063a4 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -920,7 +920,7 @@ test_done () {\r
+       GIT_EXIT_OK=t\r
+       test_results_dir="$TEST_DIRECTORY/test-results"\r
+       mkdir -p "$test_results_dir"\r
+-      test_results_path="$test_results_dir/${0%.sh}-$$"\r
++      test_results_path="$test_results_dir/${0%.sh}"\r
+ \r
+       echo "total $test_count" >> $test_results_path\r
+       echo "success $test_success" >> $test_results_path\r
+-- \r
+1.7.10.4\r
+\r