[PATCH 06/24] test: add a script to figure out source and build directories
Jani Nikula
jani at nikula.org
Mon Sep 25 13:38:22 PDT 2017
Expect the tests to be run somewhere in the build directory
hierarchy. Allow for source and build directories to be passed through
the environment.
---
test/export-dirs.sh | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 test/export-dirs.sh
diff --git a/test/export-dirs.sh b/test/export-dirs.sh
new file mode 100644
index 000000000000..0578b1e50194
--- /dev/null
+++ b/test/export-dirs.sh
@@ -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
--
2.11.0
More information about the notmuch
mailing list