summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-09-30 03:32:31 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-10-01 17:35:22 -0400
commite0b791c473dafcdc8329db49a4dbd3b7168dc20f (patch)
tree3a5ba277be9f63606d2bbba455a03155e6dd2e47
parent80c4269e7318171a2f85d491b27af9d453cab78c (diff)
test: Centalize setup in common_setup where it makes sense
-rw-r--r--test/lib-blacklist-test.sh18
-rw-r--r--test/librefetch-test.sh5
-rw-r--r--test/libremakepkg-test.sh18
-rw-r--r--test/librerelease-test.sh10
-rw-r--r--test/librestage-test.sh17
-rw-r--r--test/pkgbuild-check-nonfree-test.sh4
-rw-r--r--test/test-common.sh9
-rw-r--r--test/toru-path-test.sh2
8 files changed, 30 insertions, 53 deletions
diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh
index 920e99d..32d700d 100644
--- a/test/lib-blacklist-test.sh
+++ b/test/lib-blacklist-test.sh
@@ -3,8 +3,6 @@
describe libreblacklist
. ./test-common.sh
-_blacklist_url=https://projects.parabola.nu/blacklist.git/plain/blacklist.txt
-
it_works_with_just_pkgname() {
v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::::' ]]
v="$(libreblacklist get-pkg <<<skype)"; [[ $v == skype ]]
@@ -51,7 +49,7 @@ it_prints_urls_only_for_valid_references() {
}
it_fails_update_with_no_blacklist_or_network() {
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
BLACKLIST='phony://example.com'
eot
@@ -63,7 +61,7 @@ it_fails_update_with_no_blacklist_or_network() {
}
it_fails_cat_with_no_blacklist_or_network() {
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
BLACKLIST='phony://example.com'
eot
@@ -75,7 +73,7 @@ it_fails_cat_with_no_blacklist_or_network() {
}
it_fails_update_when_BLACKLIST_is_unset() {
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
BLACKLIST=
eot
@@ -88,8 +86,8 @@ it_fails_update_when_BLACKLIST_is_unset() {
it_fails_cat_when_syntax_error_in_conf() {
# there is a stray single quote in there
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
- BLACKLIST='${_blacklist_url@Q}
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ BLACKLIST='https://git.parabola.nu/blacklist.git/plain/blacklist.txt
eot
libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || status=$?
@@ -101,9 +99,6 @@ it_fails_cat_when_syntax_error_in_conf() {
it_downloads_the_blacklist_as_needed() {
require network || return 0
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
- BLACKLIST=${_blacklist_url@Q}
- eot
libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr
@@ -112,9 +107,6 @@ it_downloads_the_blacklist_as_needed() {
it_downloads_the_blacklist_repeatedly() {
require network || return 0
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
- BLACKLIST=${_blacklist_url@Q}
- eot
libreblacklist update
libreblacklist update
diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh
index 8cc7281..9edc227 100644
--- a/test/librefetch-test.sh
+++ b/test/librefetch-test.sh
@@ -6,16 +6,13 @@ describe librefetch
before() {
common_before
- mkdir -p "$tmpdir/workdir/srcdest"
-
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
+ cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
'rsync::/usr/bin/rsync --no-motd -z %u %o'
'scp::/usr/bin/scp -C %u %o')
BUILDDIR=""
- SRCDEST=${tmpdir@Q}/workdir/srcdest
source ${_librelib_conf_sh_sysconfdir@Q}/makepkg.d/librefetch.conf
eot
export MAKEPKG_CONF="$XDG_CONFIG_HOME/pacman/makepkg.conf"
diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh
index fd4c742..eb764c8 100644
--- a/test/libremakepkg-test.sh
+++ b/test/libremakepkg-test.sh
@@ -3,6 +3,14 @@
describe libremakepkg
. ./test-common.sh
+before() {
+ common_before
+
+ cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
+ unset PKGDEST SRCPKGDEST
+ eot
+}
+
it_builds_a_trivial_package() {
require network sudo || return 0
cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
@@ -158,14 +166,8 @@ it_detects_distcc_files() {
it_doesnt_symlink_outputs() {
require network sudo || return 0
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
- WORKDIR=${tmpdir@Q}/workdir
- eot
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
- PKGDEST=${tmpdir@Q}/workdir/pkgdest
- SRCPKGDEST=${tmpdir@Q}/workdir/srcpkgdest
- eot
- trap 'rm -f -- "$XDG_CONFIG_HOME/libretools/libretools.conf" "$XDG_CONFIG_HOME/pacman/makepkg.conf"' RETURN
+ sed -i.bak /^unset/d "$XDG_CONFIG_HOME/pacman/makepkg.conf"
+ trap 'mv -f -- "$XDG_CONFIG_HOME/pacman/makepkg.conf"{.bak,}' RETURN
cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
cd "$tmpdir"
diff --git a/test/librerelease-test.sh b/test/librerelease-test.sh
index 607df99..4a20636 100644
--- a/test/librerelease-test.sh
+++ b/test/librerelease-test.sh
@@ -6,16 +6,12 @@ describe librerelease
before() {
common_before
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
- WORKDIR=${tmpdir@Q}/workdir
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
REPODEST=ssh://repo@repo.parabola.nu:1863/~/staging/$LIBREUSER/staging/
eot
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
+ cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
PKGEXT=.pkg.tar.gz
- PKGDEST=${tmpdir@Q}/workdir/pkgdest
- GPGKEY=YOURKEY
eot
- mkdir -p "$tmpdir/workdir/pkgdest"
}
it_displays_usage_text() {
@@ -50,7 +46,7 @@ it_lists_all_files() {
}
it_fails_if_gpgkey_not_set() {
- echo 'unset GPGKEY' >> "$XDG_CONFIG_HOME"/pacman/makepkg.conf
+ unset GPGKEY
WORKDIR="$tmpdir/workdir"
mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2/sub"
diff --git a/test/librestage-test.sh b/test/librestage-test.sh
index d52cbea..2fe3415 100644
--- a/test/librestage-test.sh
+++ b/test/librestage-test.sh
@@ -3,23 +3,6 @@
describe librestage
. ./test-common.sh
-before() {
- common_before
-
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
- WORKDIR=${tmpdir@Q}/workdir
- eot
-
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot
- PKGDEST=${tmpdir@Q}/workdir/pkgdest
- SRCPKGDEST=${tmpdir@Q}/workdir/srcpkgdest
- PACKAGER='Test Suite <test@localhost>'
- eot
-
- mkdir -p "$tmpdir/workdir/pkgdest"
- mkdir -p "$tmpdir/workdir/srcpkgdest"
-}
-
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 ec1246e..0582e29 100644
--- a/test/pkgbuild-check-nonfree-test.sh
+++ b/test/pkgbuild-check-nonfree-test.sh
@@ -6,10 +6,10 @@ describe pkgbuild-check-nonfree
before() {
common_before
- install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ # Disable networking for blacklist.txt, and install a cached version instead
+ cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
BLACKLIST='phony://example.com'
eot
-
install -Dm644 /dev/stdin "$XDG_CACHE_HOME/libretools/blacklist.txt" <<-eot
linux:linux-libre:nonfree blobs and firmwares
skype
diff --git a/test/test-common.sh b/test/test-common.sh
index 81c8557..317f159 100644
--- a/test/test-common.sh
+++ b/test/test-common.sh
@@ -40,6 +40,7 @@ common_before() {
export chrootdir="${chrootdir:-$TMPDIR/chroots}"
install -Dm644 /dev/stdin "$XDG_CONFIG_HOME"/libretools/libretools.conf <<-eot
+ WORKDIR=${tmpdir@Q}/workdir
BLACKLIST=https://git.parabola.nu/blacklist.git/plain/blacklist.txt
eot
install -Dm644 /dev/stdin "$XDG_CONFIG_HOME"/libretools/chroot.conf <<-eot
@@ -47,6 +48,14 @@ common_before() {
CHROOT=default
CHROOTEXTRAPKG=()
eot
+ install -Dm644 /dev/stdin "$XDG_CONFIG_HOME"/pacman/makepkg.conf <<-eot
+ PKGDEST=${tmpdir@Q}/workdir/pkgdest
+ SRCDEST=${tmpdir@Q}/workdir/srcdest
+ SRCPKGDEST=${tmpdir@Q}/workdir/srcpkgdest
+ LOGDEST=${tmpdir@Q}/workdir/logdest
+ PACKAGER='Bob Tester <tester@localhost>'
+ eot
+ mkdir -p -- "$tmpdir"/workdir/{pkg,src,srcpkg,log}dest
}
common_after() {
diff --git a/test/toru-path-test.sh b/test/toru-path-test.sh
index 1feb341..5576ad7 100644
--- a/test/toru-path-test.sh
+++ b/test/toru-path-test.sh
@@ -11,7 +11,6 @@ it_displays_help() {
}
it_runs() {
- mkdir -p "$XDG_CONFIG_HOME"/libretools
cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
TORUPATH=${tmpdir@Q}
REPOS=(libre)
@@ -42,7 +41,6 @@ it_runs() {
}
it_sets_torupath() {
- mkdir -p "$XDG_CONFIG_HOME"/libretools
cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
TORUPATH=${tmpdir@Q}
REPOS=(libre)