#!/bin/bash NETWORK=true SUDO=true while [[ $# -gt 0 ]]; do case "$1" in --no-network) shift; unset NETWORK;; --network) shift; NETWORK=true;; --no-sudo) shift; unset SUDO;; --sudo) shift; SUDO=true;; --) shift; break;; *) break;; esac done export NETWORK SUDO export TMPDIR="$(mktemp --tmpdir -d libretools-test.XXXXXXXXXX)" trap "rm -rf '$TMPDIR'" EXIT # Set up the install to work with destdir=$TMPDIR/destdir make -C .. install-librelib install DESTDIR=$destdir &>/dev/null || { echo 'error creating local install, cannot run tests' exit 1 } 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" # Run the tests eval "$@" ret=$? # Clean up exit $ret