]> git.cworth.org Git - notmuch/blob - test/export-dirs.sh
configure: check for python cffi and pytest modules
[notmuch] / test / export-dirs.sh
1 # Source this script to set and export NOTMUCH_SRCDIR and
2 # NOTMUCH_BUILDDIR.
3 #
4 # For this to work, always have current directory somewhere within the
5 # build directory hierarchy, and run the script sourcing this script
6 # using a path (relative or absolute) to the source directory.
7
8 if [[ -z "${NOTMUCH_SRCDIR}" ]]; then
9         export NOTMUCH_SRCDIR="$(cd "$(dirname "$0")"/.. && pwd)"
10 fi
11
12 find_builddir()
13 {
14         local dir="$1"
15
16         while [[ -n "$dir" ]] && [[ "$dir" != "/" ]]; do
17                 if [[ -x "$dir/notmuch" ]] && [[ ! -d "$dir/notmuch" ]]; then
18                         echo "$dir"
19                         break
20                 fi
21                 dir="$(dirname "$dir")"
22         done
23 }
24
25 if [[ -z "${NOTMUCH_BUILDDIR}" ]]; then
26         export NOTMUCH_BUILDDIR="$(find_builddir "$(pwd)")"
27
28         if [[ -z "${NOTMUCH_BUILDDIR}" ]]; then
29                 echo "Run tests in a subdir of built notmuch tree." >&2
30                 exit 1
31         fi
32 fi