5 # Copyright (c) 2005 Junio C Hamano
6 # Copyright (c) 2010 Notmuch Developers
8 # Adapted from a Makefile to a shell script by Carl Worth (2010)
10 if [ ${BASH_VERSINFO[0]} -lt 4 ]; then
11 echo "Error: The notmuch test suite requires a bash version >= 4.0"
12 echo "due to use of associative arrays within the test suite."
13 echo "Please try again with a newer bash (or help us fix the"
14 echo "test suite to be more portable). Thanks."
18 # Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
19 . $(dirname "$0")/export-dirs.sh || exit 1
22 for test in $NOTMUCH_TESTS; do
23 TESTS="$TESTS $NOTMUCH_SRCDIR/test/$test"
26 if [[ -z "$TESTS" ]]; then
27 TESTS="$NOTMUCH_SRCDIR/test/T[0-9][0-9][0-9]-*.sh"
30 # Clean up any results from a previous run
31 rm -rf $NOTMUCH_BUILDDIR/test/test-results
33 # Test for timeout utility
34 if command -v timeout >/dev/null; then
35 TEST_TIMEOUT=${NOTMUCH_TEST_TIMEOUT:-2m}
36 if [ "$TEST_TIMEOUT" = 0 ]; then
38 echo "INFO: timeout disabled"
40 TEST_TIMEOUT_CMD="timeout $TEST_TIMEOUT"
41 echo "INFO: using $TEST_TIMEOUT timeout for tests"
47 trap 'e=$?; kill $!; exit $e' HUP INT TERM
51 if test -z "$NOTMUCH_TEST_SERIALIZE" && command -v parallel >/dev/null ; then
52 test -t 1 && export COLORS_WITHOUT_TTY=t || :
53 if parallel -h | grep -q GNU ; then
54 echo "INFO: running tests with GNU parallel"
55 printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel
57 echo "INFO: running tests with moreutils parallel"
58 $TEST_TIMEOUT_CMD parallel -- $TESTS
61 if [[ $RES != 0 ]]; then
62 META_FAILURE="parallel test suite returned error code $RES"
65 for test in $TESTS; do
66 $TEST_TIMEOUT_CMD $test "$@" &
68 # If the test failed without producing results, then it aborted,
69 # so we should abort, too.
71 testname=$(basename $test .sh)
72 if [[ $RES != 0 && ! -e "$NOTMUCH_BUILDDIR/test/test-results/$testname" ]]; then
73 META_FAILURE="Aborting on $testname (returned $RES)"
82 $NOTMUCH_SRCDIR/test/aggregate-results.sh $NOTMUCH_BUILDDIR/test/test-results/*
84 if [ -n "$META_FAILURE" ]; then
85 printf 'ERROR: %s\n' "$META_FAILURE"
92 rm -rf $NOTMUCH_BUILDDIR/test/test-results