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