]> git.notmuchmail.org Git - notmuch/blob - test/notmuch-test
test: add basic test for notmuch setup
[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 "
69 TESTS=${NOTMUCH_TESTS:=$TESTS}
70
71 # Clean up any results from a previous run
72 rm -r test-results >/dev/null 2>/dev/null
73
74 # test for timeout utility
75 if command -v timeout >/dev/null; then
76     TEST_TIMEOUT_CMD="timeout 2m "
77     echo "INFO: using 2 minute timeout for tests"
78 else
79     TEST_TIMEOUT_CMD=""
80 fi
81
82 trap 'e=$?; kill $!; exit $e' HUP INT TERM
83 # Run the tests
84 for test in $TESTS; do
85     $TEST_TIMEOUT_CMD ./$test "$@" &
86     wait $!
87     # If the test failed without producing results, then it aborted,
88     # so we should abort, too.
89     RES=$?
90     if [[ $RES != 0 && ! -e "test-results/${test%.sh}" ]]; then
91         exit $RES
92     fi
93 done
94 trap - HUP INT TERM
95
96 # Report results
97 ./aggregate-results.sh test-results/*
98
99 # Clean up
100 rm -rf test-results corpus.mail