diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-04-10 22:31:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-04-11 13:02:28 -0400 |
commit | 9d90d48c9d01fa45d1a363fc01d0a1c2ffc9e790 (patch) | |
tree | 05bb9b11c18c21ce8182e8ff0936bda8a0714acd /test | |
parent | 2a10922b475d5a78e9bdaf8a52768c767404bea0 (diff) |
test/: Tidy before()/after() definitions.
Diffstat (limited to 'test')
-rw-r--r-- | test/aur-test.sh | 9 | ||||
-rw-r--r-- | test/is_built-test.sh | 9 | ||||
-rw-r--r-- | test/lib-blacklist-test.sh | 9 | ||||
-rw-r--r-- | test/lib-conf-test.sh | 9 | ||||
-rw-r--r-- | test/lib-messages-test.sh | 9 | ||||
-rw-r--r-- | test/librechroot-test.sh | 17 | ||||
-rw-r--r-- | test/librefetch-test.sh | 9 | ||||
-rw-r--r-- | test/librelib-test.sh | 9 | ||||
-rw-r--r-- | test/libremakepkg-test.sh | 19 | ||||
-rw-r--r-- | test/librerelease-test.sh | 9 | ||||
-rw-r--r-- | test/librestage-test.sh | 9 | ||||
-rw-r--r-- | test/pkgbuild-check-nonfree-test.sh | 9 | ||||
-rw-r--r-- | test/test-common.sh | 36 |
13 files changed, 33 insertions, 129 deletions
diff --git a/test/aur-test.sh b/test/aur-test.sh index 5de590b..47f6d87 100644 --- a/test/aur-test.sh +++ b/test/aur-test.sh @@ -1,17 +1,8 @@ #!/usr/bin/env roundup describe aur - . ./test-common.sh -before() { - _before -} - -after() { - _after -} - it_displays_help() { LC_ALL=C aur -h >$tmpdir/stdout 2>$tmpdir/stderr diff --git a/test/is_built-test.sh b/test/is_built-test.sh index f7f6c65..147bdaa 100644 --- a/test/is_built-test.sh +++ b/test/is_built-test.sh @@ -1,17 +1,8 @@ #!/usr/bin/env roundup describe is_built - . ./test-common.sh -before() { - _before -} - -after() { - _after -} - it_displays_help() { LC_ALL=C is_built -h >$tmpdir/stdout 2>$tmpdir/stderr diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh index 7b06f84..49c756e 100644 --- a/test/lib-blacklist-test.sh +++ b/test/lib-blacklist-test.sh @@ -1,19 +1,10 @@ #!/usr/bin/env roundup describe libreblacklist - . ./test-common.sh _blacklist_url=https://projects.parabola.nu/blacklist.git/plain/blacklist.txt -before() { - _before -} - -after() { - _after -} - it_works_with_just_pkgname() { v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::' ]] v="$(libreblacklist get-pkg <<<skype)"; [[ $v == skype ]] diff --git a/test/lib-conf-test.sh b/test/lib-conf-test.sh index efad907..d79c5f2 100644 --- a/test/lib-conf-test.sh +++ b/test/lib-conf-test.sh @@ -1,17 +1,8 @@ #!/usr/bin/env roundup describe lib/conf.sh - . ./test-common.sh -before() { - _before test-conf.sh -} - -after() { - _after -} - it_sets_makepkg_vars_in_custom_file() { unset PKGDEST touch "$tmpdir/makepkg.conf" diff --git a/test/lib-messages-test.sh b/test/lib-messages-test.sh index d895d99..420a968 100644 --- a/test/lib-messages-test.sh +++ b/test/lib-messages-test.sh @@ -1,17 +1,8 @@ #!/usr/bin/env roundup describe libremessages - . ./test-common.sh -before() { - _before -} - -after() { - _after -} - it_can_be_included_twice() ( . libremessages . libremessages diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh index 51a43bd..fc07983 100644 --- a/test/librechroot-test.sh +++ b/test/librechroot-test.sh @@ -1,24 +1,9 @@ #!/usr/bin/env roundup describe librechroot - . ./test-common.sh -_setup_chrootdir - -before() { - _before librechroot - - mkdir -p "$XDG_CONFIG_HOME"/libretools - - 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 -} - -after() ( - _after_sudo -) +setup_chrootdir it_creates_repo_for_new_chroots() { require network sudo || return 0 diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh index f10ee7f..6871be1 100644 --- a/test/librefetch-test.sh +++ b/test/librefetch-test.sh @@ -1,15 +1,12 @@ #!/usr/bin/env roundup describe librefetch - . ./test-common.sh KEYSERVER=hkp://pool.sks-keyservers.net GPG="gpg --quiet --batch --no-tty --no-permission-warning --keyserver ${KEYSERVER}" -before() { - _before - +common_before() { mkdir -p "$XDG_CONFIG_HOME"/{pacman,libretools} "$tmpdir/srcdest" cat <<EOF > "$XDG_CONFIG_HOME/pacman/makepkg.conf" @@ -44,10 +41,6 @@ EOF | $GPG --gen-key 2>/dev/null } -after() { - _after -} - it_displays_help() { LC_ALL=C librefetch -h >$tmpdir/stdout 2>$tmpdir/stderr diff --git a/test/librelib-test.sh b/test/librelib-test.sh index 24c4478..72cbfd2 100644 --- a/test/librelib-test.sh +++ b/test/librelib-test.sh @@ -1,17 +1,8 @@ #!/usr/bin/env roundup describe librelib - . ./test-common.sh -before() { - _before -} - -after() { - _after -} - it_displays_help_and_fails_with_0_args() { ret=0 librelib >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index 2e918ad..ef4ab6a 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -1,26 +1,9 @@ #!/usr/bin/env roundup describe libremakepkg - . ./test-common.sh -_setup_chrootdir - -before() { - _before libremakepkg - - 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 -} - -after() { - _after_sudo -} +setup_chrootdir it_builds_a_trivial_package() { require network sudo || return 0 diff --git a/test/librerelease-test.sh b/test/librerelease-test.sh index a44b150..572e100 100644 --- a/test/librerelease-test.sh +++ b/test/librerelease-test.sh @@ -1,12 +1,9 @@ #!/usr/bin/env roundup describe librestage - . ./test-common.sh -before() { - _before - +common_before() { mkdir -p $XDG_CONFIG_HOME/libretools { echo "WORKDIR='$tmpdir/workdir'" @@ -20,10 +17,6 @@ before() { mkdir -p "$tmpdir/workdir/pkgdest" } -after() { - _after -} - it_displays_usage_text() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librerelease -h >"$tmpdir/stdout" 2>"$tmpdir/stderr" diff --git a/test/librestage-test.sh b/test/librestage-test.sh index affad6a..9ecbf38 100644 --- a/test/librestage-test.sh +++ b/test/librestage-test.sh @@ -1,12 +1,9 @@ #!/usr/bin/env roundup describe librestage - . ./test-common.sh -before() { - _before - +common_before() { mkdir -p $XDG_CONFIG_HOME/libretools echo "WORKDIR='$tmpdir/workdir'" > $XDG_CONFIG_HOME/libretools/libretools.conf echo "ARCHES=('x86_64' 'i686' 'misp64el')" >> $XDG_CONFIG_HOME/libretools/libretools.conf @@ -20,10 +17,6 @@ before() { mkdir -p "$tmpdir/workdir/pkgdest" } -after() { - _after -} - it_displays_usage_text() { rm -rf "$XDG_CONFIG_HOME" LC_ALL=C librestage -h >$tmpdir/stdout 2>$tmpdir/stderr diff --git a/test/pkgbuild-check-nonfree-test.sh b/test/pkgbuild-check-nonfree-test.sh index 2af2669..e6679ed 100644 --- a/test/pkgbuild-check-nonfree-test.sh +++ b/test/pkgbuild-check-nonfree-test.sh @@ -5,12 +5,9 @@ pcn=pkgbuild-check-nonfree psn=pkgbuild-summarize-nonfree describe $pcn - . ./test-common.sh -before() { - _before - +common_before() { mkdir -p $XDG_CONFIG_HOME/libretools echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf @@ -20,10 +17,6 @@ before() { echo 'skype' >>$blacklist } -after() { - _after -} - it_displays_usage_text() { # This test seems silly, but it makes sure that it is executable, # syntactically correct, and loading libraries works. 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() ( |