]> git.notmuchmail.org Git - notmuch/commitdiff
test: Abort driver if a test script aborts
authorAustin Clements <amdragon@MIT.EDU>
Wed, 28 Nov 2012 04:13:16 +0000 (23:13 -0500)
committerDavid Bremner <bremner@debian.org>
Thu, 29 Nov 2012 13:24:12 +0000 (09:24 -0400)
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
test/notmuch-test
test/test-lib.sh

index 1b842d2bf1d309029a52db2d29ca3b0a703ec859..b7feb07ef7bbb3645e9d7549a13d3928cbe31c88 100755 (executable)
@@ -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"
 
index 9a1b3758a3ee1081281532bc7b575fab0a3317ad..f2754398e9ccd53a5bd44c653235e3f9ff2936eb 100755 (executable)
@@ -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
 
index e092231589785ddc378843aa0f4e181823b4347d..77063a4d304d83709826d073ed5486df0f02d212 100644 (file)
@@ -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