]> git.notmuchmail.org Git - notmuch/blob - test/notmuch-test
fix out of tree tests
[notmuch] / test / notmuch-test
1 #!/usr/bin/env bash
2
3 # Run tests
4 #
5 # Copyright (c) 2005 Junio C Hamano
6 # Copyright (c) 2010 Notmuch Developers
7 #
8 # Adapted from a Makefile to a shell script by Carl Worth (2010)
9
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."
15     exit 1
16 fi
17
18 cd "$(dirname "$0")"
19
20 TESTS=${NOTMUCH_TESTS:-T[0-9][0-9][0-9]-*.sh}
21
22 # Clean up any results from a previous run
23 rm -rf test-results
24
25 # Test for timeout utility
26 if command -v timeout >/dev/null; then
27     TEST_TIMEOUT_CMD="timeout 2m"
28     echo "INFO: using 2 minute timeout for tests"
29 else
30     TEST_TIMEOUT_CMD=""
31 fi
32
33 trap 'e=$?; kill $!; exit $e' HUP INT TERM
34 # Run the tests
35 for test in $TESTS; do
36     $TEST_TIMEOUT_CMD ./$test "$@" &
37     wait $!
38     # If the test failed without producing results, then it aborted,
39     # so we should abort, too.
40     RES=$?
41     if [[ $RES != 0 && ! -e "test-results/${test%.sh}" ]]; then
42         exit $RES
43     fi
44 done
45 trap - HUP INT TERM
46
47 # Report results
48 echo
49 ./aggregate-results.sh test-results/*
50 ev=$?
51
52 # Clean up
53 rm -rf test-results corpus.mail
54
55 exit $ev