]> git.notmuchmail.org Git - notmuch/blob - test/notmuch-test
Merge branch 'release'
[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   config
23   setup
24   new
25   count
26   search
27   search-output
28   search-by-folder
29   search-position-overlap-bug
30   search-insufficient-from-quoting
31   search-limiting
32   excludes
33   tagging
34   json
35   sexp
36   text
37   multipart
38   thread-naming
39   raw
40   reply
41   reply-to-sender
42   dump-restore
43   uuencode
44   thread-order
45   author-order
46   from-guessing
47   long-id
48   encoding
49   emacs
50   emacs-large-search-buffer
51   emacs-subject-to-filename
52   maildir-sync
53   crypto
54   symbol-hiding
55   search-folder-coherence
56   atomicity
57   python
58   hooks
59   argument-parsing
60   emacs-test-functions
61   emacs-address-cleaning
62   emacs-hello
63   emacs-show
64   missing-headers
65   hex-escaping
66   parse-time-string
67   search-date
68   thread-replies
69 "
70 TESTS=${NOTMUCH_TESTS:=$TESTS}
71
72 # Clean up any results from a previous run
73 rm -r test-results >/dev/null 2>/dev/null
74
75 # test for timeout utility
76 if command -v timeout >/dev/null; then
77     TEST_TIMEOUT_CMD="timeout 2m "
78     echo "INFO: using 2 minute timeout for tests"
79 else
80     TEST_TIMEOUT_CMD=""
81 fi
82
83 trap 'e=$?; kill $!; exit $e' HUP INT TERM
84 # Run the tests
85 for test in $TESTS; do
86     $TEST_TIMEOUT_CMD ./$test "$@" &
87     wait $!
88     # If the test failed without producing results, then it aborted,
89     # so we should abort, too.
90     RES=$?
91     if [[ $RES != 0 && ! -e "test-results/${test%.sh}" ]]; then
92         exit $RES
93     fi
94 done
95 trap - HUP INT TERM
96
97 # Report results
98 ./aggregate-results.sh test-results/*
99
100 # Clean up
101 rm -rf test-results corpus.mail