From d60ba20ed130c5f4c4d7f22c78fb376bbda3873a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 29 Sep 2018 20:43:59 -0400 Subject: test: test-common.bash: Remove hooks from before() Instead, make the default before() an alias for common_before(), which test files can call if they override before(). --- test/libredbdiff-test.sh | 4 +++- test/librefetch-test.sh | 4 +++- test/librerelease-test.sh | 4 +++- test/librestage-test.sh | 5 +++- test/pkgbuild-check-nonfree-test.sh | 4 +++- test/test-common.sh | 47 +++++++++++++++++-------------------- 6 files changed, 38 insertions(+), 30 deletions(-) diff --git a/test/libredbdiff-test.sh b/test/libredbdiff-test.sh index 222e667..8c2f6e3 100644 --- a/test/libredbdiff-test.sh +++ b/test/libredbdiff-test.sh @@ -3,7 +3,9 @@ describe libredbdiff . ./test-common.sh -common_before() { +before() { + common_before + mkdir -p "$XDG_CONFIG_HOME/libretools" printf '%s\n' \ 'statedir="$PWD"' \ diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index 43b34fc..d734b41 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -6,7 +6,9 @@ describe librefetch KEYSERVER=hkp://pool.sks-keyservers.net GPG="gpg --quiet --batch --no-tty --no-permission-warning --keyserver ${KEYSERVER}" -common_before() { +before() { + common_before + mkdir -p "$XDG_CONFIG_HOME"/{pacman,libretools} "$tmpdir/workdir/srcdest" cat < "$XDG_CONFIG_HOME/pacman/makepkg.conf" diff --git a/test/librerelease-test.sh b/test/librerelease-test.sh index 86da995..b8e6e75 100644 --- a/test/librerelease-test.sh +++ b/test/librerelease-test.sh @@ -3,7 +3,9 @@ describe librerelease . ./test-common.sh -common_before() { +before() { + common_before + mkdir -p $XDG_CONFIG_HOME/libretools { echo "WORKDIR='$tmpdir/workdir'" diff --git a/test/librestage-test.sh b/test/librestage-test.sh index 97e7df5..7e29a3a 100644 --- a/test/librestage-test.sh +++ b/test/librestage-test.sh @@ -5,7 +5,10 @@ describe librestage setup_chrootdir -common_before() { +before() { + common_before + chroot_before + mkdir -p $XDG_CONFIG_HOME/libretools echo "WORKDIR='$tmpdir/workdir'" > $XDG_CONFIG_HOME/libretools/libretools.conf diff --git a/test/pkgbuild-check-nonfree-test.sh b/test/pkgbuild-check-nonfree-test.sh index 0d412e8..fe7459d 100644 --- a/test/pkgbuild-check-nonfree-test.sh +++ b/test/pkgbuild-check-nonfree-test.sh @@ -3,7 +3,9 @@ describe pkgbuild-check-nonfree . ./test-common.sh -common_before() { +before() { + common_before + mkdir -p $XDG_CONFIG_HOME/libretools echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf diff --git a/test/test-common.sh b/test/test-common.sh index ff43344..af7900e 100755 --- a/test/test-common.sh +++ b/test/test-common.sh @@ -7,19 +7,7 @@ fi # per-test setup/teardown ############################################ -_common_before() { - : -} - common_before() { - : -} - -common_after() { - : -} - -before() { tmpdir="$(mktemp -d --tmpdir "test-${roundup_desc//\//-}.${roundup_test_name}.XXXXXXXXXXXX")" chmod 755 "$tmpdir" @@ -47,13 +35,9 @@ before() { %commit eot export GPGKEY="$(gpg --quiet --list-secret-keys --with-colons | awk -F: '/^sec:/{print substr($5,9)}')" - - _common_before - common_before } -after() { - common_after +common_after() { gpg-connect-agent KILLAGENT /bye || true if [[ -f "$tmpdir/.used-sudo" ]]; then sudo rm -rf -- "$tmpdir" @@ -62,16 +46,29 @@ after() { fi } -setup_chrootdir() { - export chrootdir="${chrootdir:-$TMPDIR/chroots}" - _common_before() { - mkdir -p "$XDG_CONFIG_HOME"/libretools +before() { + common_before +} - echo "BLACKLIST=https://git.parabola.nu/blacklist.git/plain/blacklist.txt" >"$XDG_CONFIG_HOME"/libretools/libretools.conf +after() { + common_after +} - printf 'CHROOTDIR=%q\n' "${chrootdir}" > "$XDG_CONFIG_HOME"/libretools/chroot.conf - printf 'CHROOT=%q\n' default >> "$XDG_CONFIG_HOME"/libretools/chroot.conf - echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf +chroot_before() { + mkdir -p "$XDG_CONFIG_HOME"/libretools + + echo "BLACKLIST=https://git.parabola.nu/blacklist.git/plain/blacklist.txt" >"$XDG_CONFIG_HOME"/libretools/libretools.conf + + printf 'CHROOTDIR=%q\n' "${chrootdir}" > "$XDG_CONFIG_HOME"/libretools/chroot.conf + printf 'CHROOT=%q\n' default >> "$XDG_CONFIG_HOME"/libretools/chroot.conf + echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf +} + +setup_chrootdir() { + export chrootdir="${chrootdir:-$TMPDIR/chroots}" + before() { + common_before + chroot_before } } -- cgit v1.2.2