make test: Actually count and report on failures.

Hurrah---no more manual verification of that PASS column.

This means that "make test" can actually be a useful part of the
release process now, (since it will exit with non-zero status if there
are any failures).
This commit is contained in:
Carl Worth 2010-04-15 15:18:30 -07:00
parent 004ed3362f
commit cddeaa59ab

View file

@ -154,17 +154,23 @@ add_message ()
$NOTMUCH new > /dev/null $NOTMUCH new > /dev/null
} }
tests=0
test_failures=0
pass_if_equal () pass_if_equal ()
{ {
output=$1 output=$1
expected=$2 expected=$2
tests=$((tests + 1))
if [ "$output" = "$expected" ]; then if [ "$output" = "$expected" ]; then
echo " PASS" echo " PASS"
else else
echo " FAIL" echo " FAIL"
echo " Expected output: $expected" echo " Expected output: $expected"
echo " Actual output: $output" echo " Actual output: $output"
test_failures=$((test_failures + 1))
fi fi
} }
@ -623,9 +629,17 @@ printf " Searching returns all three messages in one thread..."
output=$($NOTMUCH search foo | notmuch_search_sanitize) output=$($NOTMUCH search foo | notmuch_search_sanitize)
pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)" pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
cat <<EOF echo ""
Notmuch test suite complete. echo "Notmuch test suite complete."
Intermediate state can be examined in: if [ "$test_failures" = "0" ]; then
${TEST_DIR} echo "All $tests tests passed."
EOF 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