2 # Copyright (c) 2005 Junio C Hamano
3 # Copyright (c) 2010 Notmuch Developers
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see http://www.gnu.org/licenses/ .
18 # This file contains common code to be used by both the regular
19 # (correctness) tests and the performance tests.
25 while [ -n "$dir" ]; do
27 if [ -x "$bin" ]; then
31 dir="$(dirname "$dir")"
32 if [ "$dir" = "/" ]; then
39 test_name=$(basename $0 .sh)
40 rm -rf notmuch-dir-backup."$test_name"
41 cp -pR ${MAIL_DIR}/.notmuch notmuch-dir-backup."${test_name}"
45 test_name=$(basename $0 .sh)
46 rm -rf ${MAIL_DIR}/.notmuch
47 cp -pR notmuch-dir-backup."${test_name}" ${MAIL_DIR}/.notmuch
50 # Test the binaries we have just built. The tests are kept in
51 # test/ subdirectory and are run in 'trash directory' subdirectory.
52 TEST_DIRECTORY=$(pwd -P)
53 notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"`
56 . $notmuch_path/sh.config || exit 1
58 if test -n "$valgrind"
62 test "$1" = "$(readlink "$2")" || {
70 while test -d "$2".lock
72 say "Waiting for lock on $2."
79 make_valgrind_symlink () {
80 # handle only executables
81 test -x "$1" || return
84 symlink_target=$TEST_DIRECTORY/../$base
85 # do not override scripts
86 if test -x "$symlink_target" &&
87 test ! -d "$symlink_target" &&
88 test "#!" != "$(head -c 2 < "$symlink_target")"
90 symlink_target=$TEST_DIRECTORY/valgrind.sh
94 symlink_target=$TEST_DIRECTORY/unprocessed-script
96 # create the link, or replace it if it is out of date
97 make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
100 # override notmuch executable in TEST_DIRECTORY/..
101 GIT_VALGRIND=$TEST_DIRECTORY/valgrind
102 mkdir -p "$GIT_VALGRIND"/bin
103 make_valgrind_symlink $TEST_DIRECTORY/../notmuch
108 ls "$path"/notmuch 2> /dev/null |
111 make_valgrind_symlink "$file"
115 PATH=$GIT_VALGRIND/bin:$PATH
116 GIT_EXEC_PATH=$GIT_VALGRIND/bin
118 test -n "$notmuch_path" && MANPATH="$notmuch_path/doc/_build/man"
120 if test -n "$notmuch_path"
122 PATH="$notmuch_path:$PATH"
123 MANPATH="$notmuch_path/doc/_build/man"
129 test="tmp.$(basename "$0" .sh)"
130 test -n "$root" && test="$root/$test"
132 /*) TMP_DIRECTORY="$test" ;;
133 *) TMP_DIRECTORY="$TEST_DIRECTORY/$test" ;;
135 test ! -z "$debug" || remove_tmp=$TMP_DIRECTORY
138 echo >&6 "FATAL: Cannot prepare test area"
142 # A temporary home directory is needed by at least:
143 # - emacs/"Sending a message via (fake) SMTP"
144 # - emacs/"Reply within emacs"
145 # - crypto/emacs_deliver_message
146 export HOME="${TMP_DIRECTORY}/home"
149 MAIL_DIR="${TMP_DIRECTORY}/mail"
150 export GNUPGHOME="${TMP_DIRECTORY}/gnupg"
151 export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
154 mkdir -p "${MAIL_DIR}"
156 cat <<EOF >"${NOTMUCH_CONFIG}"
161 name=Notmuch Test Suite
162 primary_email=test_suite@notmuchmail.org
163 other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org