aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test-lib.sh
diff options
context:
space:
mode:
authorGravatar David Bremner <bremner@debian.org>2012-11-17 16:14:41 -0400
committerGravatar David Bremner <bremner@debian.org>2012-11-25 21:11:59 -0400
commit20b7e0ff2f12e612dee00efc6ff1634aae8172a4 (patch)
tree3869a602e7b1485b92a37cddbec6443ff0931962 /test/test-lib.sh
parent0a21fb98b2a7b80958e19711d904eb91e2234250 (diff)
test: factor out part of test-lib.sh into test-lib-common.sh
The idea is to use some of the simpler parts of the test suite infrastructure to help run performance tests.
Diffstat (limited to 'test/test-lib.sh')
-rw-r--r--test/test-lib.sh129
1 files changed, 1 insertions, 128 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh
index e7638bee..467b83cf 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -1070,134 +1070,7 @@ test_init_ () {
}
-find_notmuch_path ()
-{
- dir="$1"
-
- while [ -n "$dir" ]; do
- bin="$dir/notmuch"
- if [ -x "$bin" ]; then
- echo "$dir"
- return
- fi
- dir="$(dirname "$dir")"
- if [ "$dir" = "/" ]; then
- break
- fi
- done
-}
-
-# Test the binaries we have just built. The tests are kept in
-# test/ subdirectory and are run in 'trash directory' subdirectory.
-TEST_DIRECTORY=$(pwd)
-notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"`
-if test -n "$valgrind"
-then
- make_symlink () {
- test -h "$2" &&
- test "$1" = "$(readlink "$2")" || {
- # be super paranoid
- if mkdir "$2".lock
- then
- rm -f "$2" &&
- ln -s "$1" "$2" &&
- rm -r "$2".lock
- else
- while test -d "$2".lock
- do
- say "Waiting for lock on $2."
- sleep 1
- done
- fi
- }
- }
-
- make_valgrind_symlink () {
- # handle only executables
- test -x "$1" || return
-
- base=$(basename "$1")
- symlink_target=$TEST_DIRECTORY/../$base
- # do not override scripts
- if test -x "$symlink_target" &&
- test ! -d "$symlink_target" &&
- test "#!" != "$(head -c 2 < "$symlink_target")"
- then
- symlink_target=$TEST_DIRECTORY/valgrind.sh
- fi
- case "$base" in
- *.sh|*.perl)
- symlink_target=$TEST_DIRECTORY/unprocessed-script
- esac
- # create the link, or replace it if it is out of date
- make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
- }
-
- # override notmuch executable in TEST_DIRECTORY/..
- GIT_VALGRIND=$TEST_DIRECTORY/valgrind
- mkdir -p "$GIT_VALGRIND"/bin
- make_valgrind_symlink $TEST_DIRECTORY/../notmuch
- OLDIFS=$IFS
- IFS=:
- for path in $PATH
- do
- ls "$path"/notmuch 2> /dev/null |
- while read file
- do
- make_valgrind_symlink "$file"
- done
- done
- IFS=$OLDIFS
- PATH=$GIT_VALGRIND/bin:$PATH
- GIT_EXEC_PATH=$GIT_VALGRIND/bin
- export GIT_VALGRIND
- test -n "$notmuch_path" && MANPATH="$notmuch_path/man:$MANPATH"
-else # normal case
- if test -n "$notmuch_path"
- then
- PATH="$notmuch_path:$PATH"
- MANPATH="$notmuch_path/man:$MANPATH"
- fi
-fi
-export PATH MANPATH
-
-# Test repository
-test="tmp.$(basename "$0" .sh)"
-test -n "$root" && test="$root/$test"
-case "$test" in
-/*) TMP_DIRECTORY="$test" ;;
- *) TMP_DIRECTORY="$TEST_DIRECTORY/$test" ;;
-esac
-test ! -z "$debug" || remove_tmp=$TMP_DIRECTORY
-rm -fr "$test" || {
- GIT_EXIT_OK=t
- echo >&5 "FATAL: Cannot prepare test area"
- exit 1
-}
-
-# A temporary home directory is needed by at least:
-# - emacs/"Sending a message via (fake) SMTP"
-# - emacs/"Reply within emacs"
-# - crypto/emacs_deliver_message
-export HOME="${TMP_DIRECTORY}/home"
-mkdir -p "${HOME}"
-
-MAIL_DIR="${TMP_DIRECTORY}/mail"
-export GNUPGHOME="${TMP_DIRECTORY}/gnupg"
-export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
-
-mkdir -p "${test}"
-mkdir -p "${MAIL_DIR}"
-
-cat <<EOF >"${NOTMUCH_CONFIG}"
-[database]
-path=${MAIL_DIR}
-
-[user]
-name=Notmuch Test Suite
-primary_email=test_suite@notmuchmail.org
-other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
-EOF
+. ./test-lib-common.sh
emacs_generate_script