]> git.notmuchmail.org Git - notmuch/blob - test/notmuch-test
Merge tag 'debian/0.17-2'
[notmuch] / test / notmuch-test
1 #!/usr/bin/env bash
2
3 # Run tests
4 #
5 # Copyright (c) 2005 Junio C Hamano
6 #
7 # Adapted from a Makefile to a shell script by Carl Worth (2010)
8
9 if [ ${BASH_VERSINFO[0]} -lt 4 ]; then
10     echo "Error: The notmuch test suite requires a bash version >= 4.0"
11     echo "due to use of associative arrays within the test suite."
12     echo "Please try again with a newer bash (or help us fix the"
13     echo "test suite to be more portable). Thanks."
14     exit 1
15 fi
16
17 cd $(dirname "$0")
18
19 TESTS="
20   basic
21   help-test
22   compact
23   config
24   setup
25   new
26   count
27   insert
28   search
29   search-output
30   search-by-folder
31   search-position-overlap-bug
32   search-insufficient-from-quoting
33   search-limiting
34   excludes
35   tagging
36   json
37   sexp
38   text
39   multipart
40   thread-naming
41   raw
42   reply
43   reply-to-sender
44   dump-restore
45   uuencode
46   thread-order
47   author-order
48   from-guessing
49   long-id
50   encoding
51   emacs
52   emacs-large-search-buffer
53   emacs-subject-to-filename
54   maildir-sync
55   crypto
56   symbol-hiding
57   search-folder-coherence
58   atomicity
59   python
60   hooks
61   argument-parsing
62   emacs-test-functions
63   emacs-address-cleaning
64   emacs-hello
65   emacs-show
66   emacs-tree
67   missing-headers
68   hex-escaping
69   parse-time-string
70   search-date
71   thread-replies
72 "
73 TESTS=${NOTMUCH_TESTS:=$TESTS}
74
75 # Clean up any results from a previous run
76 rm -r test-results >/dev/null 2>/dev/null
77
78 # test for timeout utility
79 if command -v timeout >/dev/null; then
80     TEST_TIMEOUT_CMD="timeout 2m "
81     echo "INFO: using 2 minute timeout for tests"
82 else
83     TEST_TIMEOUT_CMD=""
84 fi
85
86 trap 'e=$?; kill $!; exit $e' HUP INT TERM
87 # Run the tests
88 for test in $TESTS; do
89     $TEST_TIMEOUT_CMD ./$test "$@" &
90     wait $!
91     # If the test failed without producing results, then it aborted,
92     # so we should abort, too.
93     RES=$?
94     if [[ $RES != 0 && ! -e "test-results/${test%.sh}" ]]; then
95         exit $RES
96     fi
97 done
98 trap - HUP INT TERM
99
100 # Report results
101 echo
102 ./aggregate-results.sh test-results/*
103 ev=$?
104
105 # Clean up
106 rm -rf test-results corpus.mail
107
108 exit $ev