blob: 12a5901ffec0f932a23491d20dbc92b5644b06e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/bin/bash
# Parse the arguments
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
# 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"
export HOME=$TMPDIR/home
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_CONFIG_HOME="$HOME/.config"
# Run the tests
eval "$@"
|