summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-10 14:16:52 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-10 16:17:19 +0200
commit61fef4ddbec8f70bb9e213ac0491d4e6cfefab30 (patch)
tree5c27cbf2af240677949568c0e1ec34a79a9a4773 /test/integration
parent4d22a5704a0ebe19a5fa2524ac90a26c824325de (diff)
test: Automatically discover CMake build directory
Look at the project root, and all directories directly below it and pick the directory with the newest CMakeCache.txt file. Gbp-Dch: ignore
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/framework22
-rwxr-xr-xtest/integration/run-tests6
2 files changed, 27 insertions, 1 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 824bd46b6..0f442dff4 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -257,6 +257,24 @@ escape_shell() {
echo "$@" | sed -e "s#'#'\"'\"'#g"
}
+find_project_binary_dir() {
+ local TESTDIRECTORY="$(readlink -f "$(dirname $0)")"
+ if [ -z "$PROJECT_BINARY_DIR" ]; then
+ PROJECT_BINARY_DIR=
+ for dir in ${TESTDIRECTORY}/../../ ${TESTDIRECTORY}/../../*; do
+ test -e "$dir/CMakeCache.txt" || continue
+ if [ -z "$PROJECT_BINARY_DIR" ] ||
+ [ "$dir/CMakeCache.txt" -nt "$PROJECT_BINARY_DIR/CMakeCache.txt" ]; then
+ PROJECT_BINARY_DIR="$dir"
+ fi
+ done
+ if [ -z "$PROJECT_BINARY_DIR" ]; then
+ echo "Cannot find build directory, you might want to set PROJECT_BINARY_DIR" >&2
+ exit 1
+ fi
+ export PROJECT_BINARY_DIR
+ fi
+}
setupenvironment() {
# privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir)
if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then
@@ -281,9 +299,11 @@ setupenvironment() {
fi
TESTDIRECTORY="$(readlink -f "$(dirname $0)")"
+ # Find the newest build directory (sets PROJECT_BINARY_DIR)
+ find_project_binary_dir
# allow overriding the default BUILDDIR location
SOURCEDIRECTORY="${APT_INTEGRATION_TESTS_SOURCE_DIR:-"${TESTDIRECTORY}/../../"}"
- BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/cmdline"}"
+ BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${PROJECT_BINARY_DIR}/cmdline"}"
LIBRARYPATH="${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}/../apt-pkg"}"
METHODSDIR="${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/../methods"}"
APTHELPERBINDIR="${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}"
diff --git a/test/integration/run-tests b/test/integration/run-tests
index 78f24fbaf..e90b4b755 100755
--- a/test/integration/run-tests
+++ b/test/integration/run-tests
@@ -1,4 +1,10 @@
#!/bin/sh
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+find_project_binary_dir
+
set -e
TESTTORUN=''