summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-09-11 16:33:05 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-09-12 11:26:41 -0400
commiteeba3ea0411078424d8f0d127d792618c2a929d3 (patch)
tree6d69d70e09c64eed4f95c461823e1af2fa1c99bd /test
parentbd2b16fbbe43e5d879ee85da7259bdd649e4394e (diff)
test: tidy up, make everything use test-common.sh
Diffstat (limited to 'test')
-rw-r--r--test/aur-test.sh9
-rw-r--r--test/is_built-test.sh7
-rw-r--r--test/lib-blacklist-test.sh2
-rw-r--r--test/lib-messages-test.sh6
-rw-r--r--test/librechroot-test.sh3
-rw-r--r--test/librelib-test.sh7
-rw-r--r--test/libremakepkg-test.sh2
-rw-r--r--test/librestage-test.sh6
-rw-r--r--test/test-common.sh8
9 files changed, 28 insertions, 22 deletions
diff --git a/test/aur-test.sh b/test/aur-test.sh
index 1bdd2e4..1fbe659 100644
--- a/test/aur-test.sh
+++ b/test/aur-test.sh
@@ -2,13 +2,14 @@
describe aur
+. ./test-common.sh
+
before() {
- tmpdir=$(mktemp -d --tmpdir test-aur.XXXXXXXXXXXX)
- stat=0
+ _before
}
after() {
- rm -rf -- "$tmpdir"
+ _after
}
it_displays_help() {
@@ -26,4 +27,4 @@ it_fails_with_0_args() {
[[ -n "$(cat $tmpdir/stderr)" ]]
}
-# TODO: I don't have any other tests we can run without networking.
+# TODO: Actually test
diff --git a/test/is_built-test.sh b/test/is_built-test.sh
index 1bea0dc..62847e5 100644
--- a/test/is_built-test.sh
+++ b/test/is_built-test.sh
@@ -2,13 +2,14 @@
describe is_built
+. ./test-common.sh
+
before() {
- tmpdir=$(mktemp -d --tmpdir test-is_build.XXXXXXXXXXXX)
- stat=0
+ _before
}
after() {
- rm -rf -- "$tmpdir"
+ _after
}
it_displays_help() {
diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh
index 0083242..c496167 100644
--- a/test/lib-blacklist-test.sh
+++ b/test/lib-blacklist-test.sh
@@ -130,5 +130,3 @@ it_displays_help_when_given_h_cat() {
[[ "$(sed 1q $tmpdir/stdout)" == 'Usage: libreblacklist cat' ]]
[[ -z "$(cat $tmpdir/stderr)" ]]
}
-
-# TODO: test blacklist-update, but I don't want tests to use network
diff --git a/test/lib-messages-test.sh b/test/lib-messages-test.sh
index 22aad47..826556b 100644
--- a/test/lib-messages-test.sh
+++ b/test/lib-messages-test.sh
@@ -2,12 +2,14 @@
describe libremessages
+. ./test-common.sh
+
before() {
- tmpdir=$(mktemp -d --tmpdir test-libremessages.XXXXXXXXXXXX)
+ _before
}
after() {
- rm -rf -- "$tmpdir"
+ _after
}
it_can_be_included_twice() (
diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh
index 37c717a..76afb56 100644
--- a/test/librechroot-test.sh
+++ b/test/librechroot-test.sh
@@ -13,10 +13,9 @@ before() {
}
after() {
- _after
+ _after_sudo
}
-
it_creates_repo_for_new_chroots() {
require network sudo || return 0
libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty
diff --git a/test/librelib-test.sh b/test/librelib-test.sh
index 8cc2a65..e86dffe 100644
--- a/test/librelib-test.sh
+++ b/test/librelib-test.sh
@@ -2,15 +2,16 @@
describe librelib
+. ./test-common.sh
+
before() {
- tmpdir=$(mktemp -d --tmpdir test-librelib.XXXXXXXXXXXX)
+ _before
}
after() {
- rm -rf -- "$tmpdir"
+ _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 ab398bc..be19e17 100644
--- a/test/libremakepkg-test.sh
+++ b/test/libremakepkg-test.sh
@@ -17,7 +17,7 @@ before() {
}
after() {
- _after
+ _after_sudo
}
it_builds_a_trivial_package() {
diff --git a/test/librestage-test.sh b/test/librestage-test.sh
index c5097a2..849a68c 100644
--- a/test/librestage-test.sh
+++ b/test/librestage-test.sh
@@ -2,10 +2,10 @@
describe librestage
+. ./test-common.sh
before() {
- tmpdir=$(mktemp -d --tmpdir test-librestage.XXXXXXXXXXXX)
- stat=0
+ _before
mkdir -p $XDG_CONFIG_HOME/libretools
echo "WORKDIR='$tmpdir/workdir'" >$XDG_CONFIG_HOME/libretools/libretools.conf
@@ -18,7 +18,7 @@ before() {
}
after() {
- rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME"
+ _after
}
it_displays_usage_text() {
diff --git a/test/test-common.sh b/test/test-common.sh
index 85c05c5..01b1b35 100644
--- a/test/test-common.sh
+++ b/test/test-common.sh
@@ -6,11 +6,15 @@ if [[ $HOME == "$(eval echo ~$USER)" ]]; then
fi
_before() {
- tmpdir="$(mktemp -d --tmpdir "test-$1.XXXXXXXXXXXX")"
+ tmpdir="$(mktemp -d --tmpdir "test-${roundup_desc//\//-}.XXXXXXXXXXXX")"
stat=0
}
_after() {
+ rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
+}
+
+_after_sudo() {
if [[ $SUDO ]]; then
sudo rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME"
else
@@ -27,7 +31,7 @@ require() {
missing+=('sudo')
fi
if (( ${#missing[@]} )); then
- libremessages warning "Next test requires %s; Skipping (passing)..." "$(echo "${missing[@]}"|sed 's/ /, /g')" &>/dev/tty
+ libremessages warning "Next test requires %s; Skipping (passing)..." "$(echo "${missing[*]}"|sed 's/ /, /g')" &>/dev/tty
return 1
fi
return 0;