From b41bd912b9440b0663cb25960346a4fb4805d62a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 29 Sep 2018 18:34:42 -0400 Subject: =?UTF-8?q?(BATS)=20test:=20Manual=20Roundup=E2=86=92BATS=20conver?= =?UTF-8?q?sion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/.gitignore | 1 - test/cases/lib-messages.bats | 14 ++++++++------ test/cases/librechroot.bats | 4 ++-- test/cases/librefetch.bats | 2 +- test/cases/libremakepkg.bats | 4 ++-- test/lib/common.bash | 15 +++++++-------- 6 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 test/.gitignore (limited to 'test') 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 -- cgit v1.2.2