summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-09-29 18:34:42 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-10-01 20:31:57 -0400
commitb41bd912b9440b0663cb25960346a4fb4805d62a (patch)
tree092efcee116c9ac477e88654cb6b424ffe355201 /test
parent00406ddaa210e0e9a6e31e0e6841b51edabc80fb (diff)
(BATS) test: Manual Roundup→BATS conversion
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore1
-rw-r--r--test/cases/lib-messages.bats14
-rw-r--r--test/cases/librechroot.bats4
-rw-r--r--test/cases/librefetch.bats2
-rw-r--r--test/cases/libremakepkg.bats4
-rw-r--r--test/lib/common.bash15
6 files changed, 20 insertions, 20 deletions
diff --git a/test/.gitignore b/test/.gitignore
deleted file mode 100644
index 2226ac6..0000000
--- a/test/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-.roundup.*
diff --git a/test/cases/lib-messages.bats b/test/cases/lib-messages.bats
index c992a33..69a5f09 100644
--- a/test/cases/lib-messages.bats
+++ b/test/cases/lib-messages.bats
@@ -1,14 +1,16 @@
load ../lib/common
-@test "libremessages can be included twice" (
+@test "libremessages can be included twice" {
. libremessages
. libremessages
-)
+}
-@test "libremessages can be included with set euE" (
- set -euE
- . libremessages
-)
+@test "libremessages can be included with set euE" {
+ ( # use a subshell because BATS doesn't like `set -u`
+ set -euE
+ . libremessages
+ )
+}
@test "libremessages works with no color and set euE" {
(
diff --git a/test/cases/librechroot.bats b/test/cases/librechroot.bats
index 7e8504d..7d05ebc 100644
--- a/test/cases/librechroot.bats
+++ b/test/cases/librechroot.bats
@@ -13,13 +13,13 @@ load ../lib/common
# TODO: inspect /repo/* more
}
-@test "librechroot respects exit status if out isnt a tty" (
+@test "librechroot respects exit status if out isnt a tty" {
require network sudo || skip
set -o pipefail
{ testsudo librechroot -l "$BATS_TEST_NAME" run bash -c 'exit 3' | cat; } || status=$?
[[ $status == 3 ]]
-)
+}
@test "librechroot creates ca certificates" {
require network sudo || skip
diff --git a/test/cases/librefetch.bats b/test/cases/librefetch.bats
index 47cd9bd..8f03494 100644
--- a/test/cases/librefetch.bats
+++ b/test/cases/librefetch.bats
@@ -41,7 +41,7 @@ setup() {
not test -e $tmpdir/workdir/srcdest/$srcball
}
-# This test used to be called "it_cleans_src_libre_first", but let's
+# This test used to be called "librefetch cleans src-libre first", but let's
# be honest: it checks pretty much everything related to normal
# operation.
@test "librefetch runs with mksource" {
diff --git a/test/cases/libremakepkg.bats b/test/cases/libremakepkg.bats
index 8ac46cf..d511c38 100644
--- a/test/cases/libremakepkg.bats
+++ b/test/cases/libremakepkg.bats
@@ -76,8 +76,8 @@ setup() {
testsudo libremakepkg -l "$BATS_TEST_NAME" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; }
testsudo librechroot -l "$BATS_TEST_NAME" run libretools-testpkg1 'first time, pass'
- # This next line is actually a separate test, but it fits in well with this test, and chroot tests are slow..
- # it_doesnt_cache_local_packages() {
+ # This next line is actually a separate test, but it fits in well with this test, and chroot tests are slow.
+ # @test "libremakepkg doesnt cache local packages" {
not testsudo librechroot -l "$BATS_TEST_NAME" run test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar.?z
cd "$tmpdir/3"
diff --git a/test/lib/common.bash b/test/lib/common.bash
index b7e9c10..12daee0 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -7,8 +7,8 @@ fi
# per-test setup/teardown ############################################
-common_before() {
- tmpdir="$(mktemp -d --tmpdir "test-${roundup_desc//\//-}.${roundup_test_name}.XXXXXXXXXXXX")"
+common_setup() {
+ tmpdir="$(mktemp -d --tmpdir "test-${BATS_TEST_NAME}.XXXXXXXXXXXX")"
chmod 755 "$tmpdir"
status=0
@@ -59,7 +59,7 @@ common_before() {
mkdir -p -- "$tmpdir"/workdir/{pkg,src,srcpkg,log}dest
}
-common_after() {
+common_teardown() {
gpg-connect-agent KILLAGENT /bye || true
if [[ -f "$tmpdir/.used-sudo" ]]; then
sudo rm -rf -- "$tmpdir"
@@ -68,12 +68,12 @@ common_after() {
fi
}
-before() {
- common_before
+setup() {
+ common_setup
}
-after() {
- common_after
+teardown() {
+ common_teardown
}
# Utility functions for use in test definitions ######################
@@ -91,7 +91,6 @@ require() (
missing+=('btrfs')
fi
if (( ${#missing[@]} )); then
- libremessages warning "Next test requires %s; Skipping (passing)..." "$(echo "${missing[*]}"|sed 's/ /, /g')" &>/dev/tty
return 1
fi
if libremessages in_array "sudo" "$@"; then