mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
test: add a script to figure out source and build directories
Expect the tests to be run somewhere in the build directory hierarchy. Allow for source and build directories to be passed through the environment.
This commit is contained in:
parent
e1bd4f2363
commit
1f3c114f08
1 changed files with 32 additions and 0 deletions
32
test/export-dirs.sh
Normal file
32
test/export-dirs.sh
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# Source this script to set and export NOTMUCH_SRCDIR and
|
||||||
|
# NOTMUCH_BUILDDIR.
|
||||||
|
#
|
||||||
|
# For this to work, always have current directory somewhere within the
|
||||||
|
# build directory hierarchy, and run the script sourcing this script
|
||||||
|
# using a path (relative or absolute) to the source directory.
|
||||||
|
|
||||||
|
if [[ -z "${NOTMUCH_SRCDIR}" ]]; then
|
||||||
|
export NOTMUCH_SRCDIR="$(cd "$(dirname "$0")"/.. && pwd)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
find_builddir()
|
||||||
|
{
|
||||||
|
local dir="$1"
|
||||||
|
|
||||||
|
while [[ -n "$dir" ]] && [[ "$dir" != "/" ]]; do
|
||||||
|
if [[ -x "$dir/notmuch" ]] && [[ ! -d "$dir/notmuch" ]]; then
|
||||||
|
echo "$dir"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
dir="$(dirname "$dir")"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -z "${NOTMUCH_BUILDDIR}" ]]; then
|
||||||
|
export NOTMUCH_BUILDDIR="$(find_builddir "$(pwd)")"
|
||||||
|
|
||||||
|
if [[ -z "${NOTMUCH_BUILDDIR}" ]]; then
|
||||||
|
echo "Run tests in a subdir of built notmuch tree." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in a new issue