summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/testenv23
1 files changed, 14 insertions, 9 deletions
diff --git a/test/testenv b/test/testenv
index 0448e33..12a5901 100755
--- a/test/testenv
+++ b/test/testenv
@@ -1,5 +1,6 @@
#!/bin/bash
+# Parse the arguments
NETWORK=true
SUDO=true
while [[ $# -gt 0 ]]; do
@@ -14,25 +15,29 @@ while [[ $# -gt 0 ]]; do
done
export NETWORK SUDO
+# Set up the working directory, and add the hook to clean it up
export TMPDIR="$(mktemp --tmpdir -d libretools-test.XXXXXXXXXX)"
trap "rm -rf '$TMPDIR'" EXIT
+
# Set up the install to work with
destdir=$TMPDIR/destdir
+
+old_pwd="$(pwd)"
+if [[ -f $0 ]]; then
+ cd "${0%/*}"
+fi
make -C .. install DESTDIR=$destdir &>/dev/null || {
echo 'error creating local install, cannot run tests'
exit 1
}
+cd "$old_pwd"
+
+# Set up the environment
export PATH="$destdir/usr/bin:$destdir/usr/sbin:$PATH"
export LIBRETOOLS_LIBDIR="$destdir/usr/lib/libretools"
-
-# Set up the user profile
-home=$TMPDIR/home
-export XDG_CACHE_HOME="$home/.cache"
-export XDG_CONFIG_HOME="$home/.config"
+export HOME=$TMPDIR/home
+export XDG_CACHE_HOME="$HOME/.cache"
+export XDG_CONFIG_HOME="$HOME/.config"
# Run the tests
eval "$@"
-ret=$?
-
-# Clean up
-exit $ret