summaryrefslogtreecommitdiff
path: root/test/test-common.sh
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-04-10 22:31:02 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-04-11 13:02:28 -0400
commit9d90d48c9d01fa45d1a363fc01d0a1c2ffc9e790 (patch)
tree05bb9b11c18c21ce8182e8ff0936bda8a0714acd /test/test-common.sh
parent2a10922b475d5a78e9bdaf8a52768c767404bea0 (diff)
test/: Tidy before()/after() definitions.
Diffstat (limited to 'test/test-common.sh')
-rw-r--r--test/test-common.sh36
1 files changed, 27 insertions, 9 deletions
diff --git a/test/test-common.sh b/test/test-common.sh
index c1d050a..f81738a 100644
--- a/test/test-common.sh
+++ b/test/test-common.sh
@@ -5,7 +5,15 @@ if [[ $HOME == "$(eval echo ~$USER)" ]]; then
exit 1
fi
-_before() {
+common_before() {
+ :
+}
+
+common_after() {
+ :
+}
+
+before() {
unset PKGDEST SRCDEST SRCPKGDEST LOGDEST
unset BUILDDIR
unset PKGEXT SRCEXT
@@ -13,25 +21,32 @@ _before() {
tmpdir="$(mktemp -d --tmpdir "test-${roundup_desc//\//-}.XXXXXXXXXXXX")"
chmod 755 "$tmpdir"
stat=0
+ common_before
}
-_after() {
- rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
-}
-
-_after_sudo() {
- if [[ $SUDO ]]; then
+after() {
+ common_after
+ if [[ -f "$tmpdir/.used-sudo" ]]; then
sudo rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
else
rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
fi
}
-_setup_chrootdir() {
+setup_chrootdir() {
if [[ -z "$chrootdir" ]]; then
export chrootdir="$(mktemp -d --tmpdir "test-chrootdir.XXXXXXXXXXXX")"
trap "$(printf '_cleanup_chrootdir %q' "$chrootdir")" EXIT
fi
+ common_before() {
+ mkdir -p "$XDG_CONFIG_HOME"/libretools
+
+ echo "BLACKLIST=https://git.parabola.nu/blacklist.git/plain/blacklist.txt" >"$XDG_CONFIG_HOME"/libretools/libretools.conf
+
+ echo "CHROOTDIR='${chrootdir}'" > "$XDG_CONFIG_HOME"/libretools/chroot.conf
+ echo "CHROOT='default'" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
+ echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf
+ }
}
_cleanup_chrootdir() (
@@ -67,7 +82,10 @@ require() (
libremessages warning "Next test requires %s; Skipping (passing)..." "$(echo "${missing[*]}"|sed 's/ /, /g')" &>/dev/tty
return 1
fi
- return 0;
+ if libremessages in_array "sudo" "$@"; then
+ touch "$tmpdir/.used-sudo"
+ fi
+ return 0
)
empty() (