]> git.notmuchmail.org Git - notmuch/blobdiff - test/notmuch-test
make test: Actually count and report on failures.
[notmuch] / test / notmuch-test
index ba1e70f6fb7c48d6c6bd1fbee27366069b686c4f..53ee1892b0d839cd22f74bef339be83674ce8327 100755 (executable)
@@ -154,17 +154,23 @@ add_message ()
     $NOTMUCH new > /dev/null
 }
 
+tests=0
+test_failures=0
+
 pass_if_equal ()
 {
     output=$1
     expected=$2
 
+    tests=$((tests + 1))
+
     if [ "$output" = "$expected" ]; then
        echo "  PASS"
     else
        echo "  FAIL"
        echo "  Expected output: $expected"
        echo "  Actual output:   $output"
+       test_failures=$((test_failures + 1))
     fi
 }
 
@@ -583,34 +589,22 @@ printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
 
 printf " Dumping all tags...\t\t\t\t"
 $NOTMUCH dump dump.expected
-echo " PASS"
+pass_if_equal "$?" "0"
 
 printf " Clearing all tags...\t\t\t\t"
 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
 $NOTMUCH restore clear.expected
 $NOTMUCH dump clear.actual
-if diff clear.expected clear.actual > /dev/null; then
-    echo "     PASS"
-else
-    echo "     FAIL"
-    echo "     Expected output: See file clear.expected"
-    echo "     Actual output:   See file clear.actual"
-fi
+pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
 
 printf " Restoring original tags...\t\t\t"
 $NOTMUCH restore dump.expected
 $NOTMUCH dump dump.actual
-if diff dump.expected dump.actual > /dev/null; then
-    echo "     PASS"
-else
-    echo "     FAIL"
-    echo "     Expected output: See file dump.expected"
-    echo "     Actual output:   See file dump.actual"
-fi
+pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
 
 printf " Restore with nothing to do...\t\t\t"
 $NOTMUCH restore dump.expected
-echo " PASS"
+pass_if_equal "$?" "0"
 
 printf "\nTesting threading when messages received out of order:\n"
 printf " Adding initial child message...\t\t"
@@ -635,9 +629,17 @@ printf " Searching returns all three messages in one thread..."
 output=$($NOTMUCH search foo | notmuch_search_sanitize)
 pass_if_equal "$output" "thread:XXX   2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
 
-cat <<EOF
-Notmuch test suite complete.
+echo ""
+echo "Notmuch test suite complete."
 
-Intermediate state can be examined in:
-       ${TEST_DIR}
-EOF
+if [ "$test_failures" = "0" ]; then
+    echo "All $tests tests passed."
+    rm -rf ${TEST_DIR}
+else
+    echo "$test_failures/$tests tests failed. The failures can be investigated in:"
+    echo "${TEST_DIR}"
+fi
+
+echo ""
+
+exit $test_failures