From f2294c82afae36bbd5772a86c6689fd4c12c50f0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 29 Sep 2018 15:00:21 -0400 Subject: (BATS) test: Move files around But don't edit them yet. This directory structure is based on that of dbscripts. --- test/aur-test.sh | 21 -- test/cases/aur.bats | 21 ++ test/cases/gitget.bats | 40 ++++ test/cases/is_built.bats | 51 +++++ test/cases/lib-blacklist.bats | 135 ++++++++++++ test/cases/lib-conf.bats | 46 ++++ test/cases/lib-messages.bats | 63 ++++++ test/cases/librechroot.bats | 192 +++++++++++++++++ test/cases/libredbdiff.bats | 50 +++++ test/cases/librefetch.bats | 135 ++++++++++++ test/cases/librelib.bats | 63 ++++++ test/cases/libremakepkg.bats | 240 +++++++++++++++++++++ test/cases/librerelease.bats | 53 +++++ test/cases/librestage.bats | 71 ++++++ test/cases/librexgettext.bats | 58 +++++ test/cases/pkgbuild-check-nonfree.bats | 68 ++++++ test/cases/toru-path.bats | 56 +++++ test/fixtures/librechroot/PKGBUILD-arches | 22 ++ test/fixtures/librechroot/PKGBUILD-libretools | 20 ++ test/fixtures/libredbdiff/expected-explicit.txt | 1 + test/fixtures/libredbdiff/expected-implicit.txt | 2 + .../pacman.archlinux/local/ALPM_DB_VERSION | 1 + .../statedir/pacman.archlinux/sync/core.db | Bin 0 -> 1017 bytes .../libredbdiff/statedir/pacman.conf.archlinux | 6 + .../libredbdiff/statedir/pacman.conf.parabola | 6 + .../statedir/pacman.parabola/local/ALPM_DB_VERSION | 1 + .../statedir/pacman.parabola/sync/libre.db | Bin 0 -> 1062 bytes test/fixtures/librefetch/PKGBUILD-mksource | 19 ++ test/fixtures/librefetch/PKGBUILD-recurse | 18 ++ test/fixtures/librefetch/PKGBUILD-srcbuild | 10 + test/fixtures/librefetch/SRCBUILD-srcbuild | 21 ++ test/fixtures/librefetch/list.txt | 5 + test/fixtures/libremakepkg/PKGBUILD-distcc | 23 ++ test/fixtures/libremakepkg/PKGBUILD-hello | 19 ++ test/fixtures/libremakepkg/PKGBUILD-netbuild | 17 ++ test/fixtures/libremakepkg/PKGBUILD-netpackage | 12 ++ test/fixtures/libremakepkg/PKGBUILD-netprepare | 17 ++ test/fixtures/libremakepkg/PKGBUILD-pkgver | 23 ++ test/fixtures/libremakepkg/PKGBUILD-signed | 17 ++ test/fixtures/libremakepkg/PKGBUILD-testpkg1 | 19 ++ test/fixtures/libremakepkg/PKGBUILD-testpkg2 | 19 ++ test/fixtures/libremakepkg/hello.sh | 2 + test/fixtures/librestage/PKGBUILD-hello | 19 ++ test/fixtures/librexgettext/.gitignore | 1 + test/fixtures/librexgettext/combine.pot | 15 ++ test/fixtures/librexgettext/combine1.sh | 5 + test/fixtures/librexgettext/combine2.sh | 5 + ...text_fails_on_missing_final_flag_description.sh | 4 + ...xgettext_fails_on_subshell_flag_descriptions.sh | 7 + ...test_librexgettext_handles_librefetch_flags.pot | 40 ++++ .../test_librexgettext_handles_librefetch_flags.sh | 15 ++ ...ibrexgettext_handles_multiple_skipped_flags.pot | 58 +++++ ...librexgettext_handles_multiple_skipped_flags.sh | 17 ++ .../test_librexgettext_handles_zero_flags.pot | 0 .../test_librexgettext_handles_zero_flags.sh | 4 + test/fixtures/pkgbuild-check-nonfree/PKGBUILD.free | 18 ++ .../pkgbuild-check-nonfree/PKGBUILD.nonfree | 18 ++ .../PKGBUILD.nonfree-replacement | 18 ++ test/fixtures/toru/libre/simple/PKGBUILD | 11 + test/fixtures/toru/libre/split-base/PKGBUILD | 20 ++ test/fixtures/toru/libre/split/PKGBUILD | 19 ++ test/gitget-test.sh | 40 ---- test/is_built-test.sh | 51 ----- test/lib-blacklist-test.sh | 135 ------------ test/lib-conf-test.sh | 46 ---- test/lib-messages-test.sh | 63 ------ test/lib/common.bash | 128 +++++++++++ test/librechroot-test.sh | 192 ----------------- test/librechroot.d/PKGBUILD-arches | 22 -- test/librechroot.d/PKGBUILD-libretools | 20 -- test/libredbdiff-test.sh | 50 ----- test/libredbdiff.d/expected-explicit.txt | 1 - test/libredbdiff.d/expected-implicit.txt | 2 - .../pacman.archlinux/local/ALPM_DB_VERSION | 1 - .../statedir/pacman.archlinux/sync/core.db | Bin 1017 -> 0 bytes test/libredbdiff.d/statedir/pacman.conf.archlinux | 6 - test/libredbdiff.d/statedir/pacman.conf.parabola | 6 - .../statedir/pacman.parabola/local/ALPM_DB_VERSION | 1 - .../statedir/pacman.parabola/sync/libre.db | Bin 1062 -> 0 bytes test/librefetch-test.sh | 135 ------------ test/librefetch.d/PKGBUILD-mksource | 19 -- test/librefetch.d/PKGBUILD-recurse | 18 -- test/librefetch.d/PKGBUILD-srcbuild | 10 - test/librefetch.d/SRCBUILD-srcbuild | 21 -- test/librefetch.d/list.txt | 5 - test/librelib-test.sh | 63 ------ test/libremakepkg-test.sh | 240 --------------------- test/libremakepkg.d/PKGBUILD-distcc | 23 -- test/libremakepkg.d/PKGBUILD-hello | 19 -- test/libremakepkg.d/PKGBUILD-netbuild | 17 -- test/libremakepkg.d/PKGBUILD-netpackage | 12 -- test/libremakepkg.d/PKGBUILD-netprepare | 17 -- test/libremakepkg.d/PKGBUILD-pkgver | 23 -- test/libremakepkg.d/PKGBUILD-signed | 17 -- test/libremakepkg.d/PKGBUILD-testpkg1 | 19 -- test/libremakepkg.d/PKGBUILD-testpkg2 | 19 -- test/libremakepkg.d/hello.sh | 2 - test/librerelease-test.sh | 53 ----- test/librestage-test.sh | 71 ------ test/librestage.d/PKGBUILD-hello | 19 -- test/librexgettext-test.sh | 58 ----- test/librexgettext.d/.gitignore | 1 - test/librexgettext.d/combine.pot | 15 -- test/librexgettext.d/combine1.sh | 5 - test/librexgettext.d/combine2.sh | 5 - .../it_fails_on_missing_final_flag_description.sh | 4 - .../it_fails_on_subshell_flag_descriptions.sh | 7 - .../it_handles_librefetch_flags.pot | 40 ---- .../librexgettext.d/it_handles_librefetch_flags.sh | 15 -- .../it_handles_multiple_skipped_flags.pot | 58 ----- .../it_handles_multiple_skipped_flags.sh | 17 -- test/librexgettext.d/it_handles_zero_flags.pot | 0 test/librexgettext.d/it_handles_zero_flags.sh | 4 - test/pkgbuild-check-nonfree-test.sh | 68 ------ test/pkgbuild-check-nonfree.d/PKGBUILD.free | 18 -- test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree | 18 -- .../PKGBUILD.nonfree-replacement | 18 -- test/test-common.sh | 128 ----------- test/toru-path-test.sh | 56 ----- test/toru.d/libre/simple/PKGBUILD | 11 - test/toru.d/libre/split-base/PKGBUILD | 20 -- test/toru.d/libre/split/PKGBUILD | 19 -- 122 files changed, 2064 insertions(+), 2064 deletions(-) delete mode 100644 test/aur-test.sh create mode 100644 test/cases/aur.bats create mode 100644 test/cases/gitget.bats create mode 100644 test/cases/is_built.bats create mode 100644 test/cases/lib-blacklist.bats create mode 100644 test/cases/lib-conf.bats create mode 100644 test/cases/lib-messages.bats create mode 100644 test/cases/librechroot.bats create mode 100644 test/cases/libredbdiff.bats create mode 100644 test/cases/librefetch.bats create mode 100644 test/cases/librelib.bats create mode 100644 test/cases/libremakepkg.bats create mode 100644 test/cases/librerelease.bats create mode 100644 test/cases/librestage.bats create mode 100644 test/cases/librexgettext.bats create mode 100644 test/cases/pkgbuild-check-nonfree.bats create mode 100644 test/cases/toru-path.bats create mode 100644 test/fixtures/librechroot/PKGBUILD-arches create mode 100644 test/fixtures/librechroot/PKGBUILD-libretools create mode 100644 test/fixtures/libredbdiff/expected-explicit.txt create mode 100644 test/fixtures/libredbdiff/expected-implicit.txt create mode 100644 test/fixtures/libredbdiff/statedir/pacman.archlinux/local/ALPM_DB_VERSION create mode 100644 test/fixtures/libredbdiff/statedir/pacman.archlinux/sync/core.db create mode 100644 test/fixtures/libredbdiff/statedir/pacman.conf.archlinux create mode 100644 test/fixtures/libredbdiff/statedir/pacman.conf.parabola create mode 100644 test/fixtures/libredbdiff/statedir/pacman.parabola/local/ALPM_DB_VERSION create mode 100644 test/fixtures/libredbdiff/statedir/pacman.parabola/sync/libre.db create mode 100644 test/fixtures/librefetch/PKGBUILD-mksource create mode 100644 test/fixtures/librefetch/PKGBUILD-recurse create mode 100644 test/fixtures/librefetch/PKGBUILD-srcbuild create mode 100644 test/fixtures/librefetch/SRCBUILD-srcbuild create mode 100644 test/fixtures/librefetch/list.txt create mode 100644 test/fixtures/libremakepkg/PKGBUILD-distcc create mode 100644 test/fixtures/libremakepkg/PKGBUILD-hello create mode 100644 test/fixtures/libremakepkg/PKGBUILD-netbuild create mode 100644 test/fixtures/libremakepkg/PKGBUILD-netpackage create mode 100644 test/fixtures/libremakepkg/PKGBUILD-netprepare create mode 100644 test/fixtures/libremakepkg/PKGBUILD-pkgver create mode 100644 test/fixtures/libremakepkg/PKGBUILD-signed create mode 100644 test/fixtures/libremakepkg/PKGBUILD-testpkg1 create mode 100644 test/fixtures/libremakepkg/PKGBUILD-testpkg2 create mode 100644 test/fixtures/libremakepkg/hello.sh create mode 100644 test/fixtures/librestage/PKGBUILD-hello create mode 100644 test/fixtures/librexgettext/.gitignore create mode 100644 test/fixtures/librexgettext/combine.pot create mode 100644 test/fixtures/librexgettext/combine1.sh create mode 100644 test/fixtures/librexgettext/combine2.sh create mode 100644 test/fixtures/librexgettext/test_librexgettext_fails_on_missing_final_flag_description.sh create mode 100644 test/fixtures/librexgettext/test_librexgettext_fails_on_subshell_flag_descriptions.sh create mode 100644 test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.pot create mode 100644 test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.sh create mode 100644 test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.pot create mode 100644 test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.sh create mode 100644 test/fixtures/librexgettext/test_librexgettext_handles_zero_flags.pot create mode 100644 test/fixtures/librexgettext/test_librexgettext_handles_zero_flags.sh create mode 100644 test/fixtures/pkgbuild-check-nonfree/PKGBUILD.free create mode 100644 test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree create mode 100644 test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree-replacement create mode 100644 test/fixtures/toru/libre/simple/PKGBUILD create mode 100644 test/fixtures/toru/libre/split-base/PKGBUILD create mode 100644 test/fixtures/toru/libre/split/PKGBUILD delete mode 100644 test/gitget-test.sh delete mode 100644 test/is_built-test.sh delete mode 100644 test/lib-blacklist-test.sh delete mode 100644 test/lib-conf-test.sh delete mode 100644 test/lib-messages-test.sh create mode 100644 test/lib/common.bash delete mode 100644 test/librechroot-test.sh delete mode 100644 test/librechroot.d/PKGBUILD-arches delete mode 100644 test/librechroot.d/PKGBUILD-libretools delete mode 100644 test/libredbdiff-test.sh delete mode 100644 test/libredbdiff.d/expected-explicit.txt delete mode 100644 test/libredbdiff.d/expected-implicit.txt delete mode 100644 test/libredbdiff.d/statedir/pacman.archlinux/local/ALPM_DB_VERSION delete mode 100644 test/libredbdiff.d/statedir/pacman.archlinux/sync/core.db delete mode 100644 test/libredbdiff.d/statedir/pacman.conf.archlinux delete mode 100644 test/libredbdiff.d/statedir/pacman.conf.parabola delete mode 100644 test/libredbdiff.d/statedir/pacman.parabola/local/ALPM_DB_VERSION delete mode 100644 test/libredbdiff.d/statedir/pacman.parabola/sync/libre.db delete mode 100644 test/librefetch-test.sh delete mode 100644 test/librefetch.d/PKGBUILD-mksource delete mode 100644 test/librefetch.d/PKGBUILD-recurse delete mode 100644 test/librefetch.d/PKGBUILD-srcbuild delete mode 100644 test/librefetch.d/SRCBUILD-srcbuild delete mode 100644 test/librefetch.d/list.txt delete mode 100644 test/librelib-test.sh delete mode 100644 test/libremakepkg-test.sh delete mode 100644 test/libremakepkg.d/PKGBUILD-distcc delete mode 100644 test/libremakepkg.d/PKGBUILD-hello delete mode 100644 test/libremakepkg.d/PKGBUILD-netbuild delete mode 100644 test/libremakepkg.d/PKGBUILD-netpackage delete mode 100644 test/libremakepkg.d/PKGBUILD-netprepare delete mode 100644 test/libremakepkg.d/PKGBUILD-pkgver delete mode 100644 test/libremakepkg.d/PKGBUILD-signed delete mode 100644 test/libremakepkg.d/PKGBUILD-testpkg1 delete mode 100644 test/libremakepkg.d/PKGBUILD-testpkg2 delete mode 100644 test/libremakepkg.d/hello.sh delete mode 100644 test/librerelease-test.sh delete mode 100644 test/librestage-test.sh delete mode 100644 test/librestage.d/PKGBUILD-hello delete mode 100644 test/librexgettext-test.sh delete mode 100644 test/librexgettext.d/.gitignore delete mode 100644 test/librexgettext.d/combine.pot delete mode 100644 test/librexgettext.d/combine1.sh delete mode 100644 test/librexgettext.d/combine2.sh delete mode 100644 test/librexgettext.d/it_fails_on_missing_final_flag_description.sh delete mode 100644 test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh delete mode 100644 test/librexgettext.d/it_handles_librefetch_flags.pot delete mode 100644 test/librexgettext.d/it_handles_librefetch_flags.sh delete mode 100644 test/librexgettext.d/it_handles_multiple_skipped_flags.pot delete mode 100644 test/librexgettext.d/it_handles_multiple_skipped_flags.sh delete mode 100644 test/librexgettext.d/it_handles_zero_flags.pot delete mode 100644 test/librexgettext.d/it_handles_zero_flags.sh delete mode 100644 test/pkgbuild-check-nonfree-test.sh delete mode 100644 test/pkgbuild-check-nonfree.d/PKGBUILD.free delete mode 100644 test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree delete mode 100644 test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree-replacement delete mode 100644 test/test-common.sh delete mode 100644 test/toru-path-test.sh delete mode 100644 test/toru.d/libre/simple/PKGBUILD delete mode 100644 test/toru.d/libre/split-base/PKGBUILD delete mode 100644 test/toru.d/libre/split/PKGBUILD (limited to 'test') diff --git a/test/aur-test.sh b/test/aur-test.sh deleted file mode 100644 index fbb3266..0000000 --- a/test/aur-test.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env roundup - -describe aur -. ./test-common.sh - -it_displays_help() { - LC_ALL=C aur -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_fails_with_0_args() { - aur >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -# TODO: Actually test diff --git a/test/cases/aur.bats b/test/cases/aur.bats new file mode 100644 index 0000000..fbb3266 --- /dev/null +++ b/test/cases/aur.bats @@ -0,0 +1,21 @@ +#!/usr/bin/env roundup + +describe aur +. ./test-common.sh + +it_displays_help() { + LC_ALL=C aur -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_fails_with_0_args() { + aur >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +# TODO: Actually test diff --git a/test/cases/gitget.bats b/test/cases/gitget.bats new file mode 100644 index 0000000..1630fdb --- /dev/null +++ b/test/cases/gitget.bats @@ -0,0 +1,40 @@ +#!/usr/bin/env roundup + +describe gitget +. ./test-common.sh + +it_displays_help() { + LC_ALL=C gitget -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_fails_with_0_args() { + gitget >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_forces_url_for_bare() { + mkdir "$tmpdir/src" + cd "$tmpdir/src" + git init . + git config --local user.email 'libretools-test@localhost' + git config --local user.name 'Test Suite' + echo a > a + git add . + git commit -m 'initial commit' + cd .. + gitget bare src dst.git + cd dst.git + [[ "$(git config --get remote.origin.url)" == "$tmpdir/src" ]] + cd .. + gitget bare "file://$PWD/src" dst.git || status=$? + [[ $status != 0 ]] + gitget -f bare "file://$PWD/src" dst.git + cd dst.git + [[ "$(git config --get remote.origin.url)" == "file://$tmpdir/src" ]] +} diff --git a/test/cases/is_built.bats b/test/cases/is_built.bats new file mode 100644 index 0000000..66f92bf --- /dev/null +++ b/test/cases/is_built.bats @@ -0,0 +1,51 @@ +#!/usr/bin/env roundup + +describe is_built +. ./test-common.sh + +it_displays_help() { + LC_ALL=C is_built -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_fails_with_0_args() { + is_built >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status -gt 1 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_succeeds_with_1_arg() { + is_built sh >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stdout + empty $tmpdir/stderr +} + +it_returns_1_for_non_existent_package() { + is_built phony-ne-package 100 >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status == 1 ]] + empty $tmpdir/stdout + empty $tmpdir/stderr +} + +it_returns_1_for_future_packages() { + # If emacs ever goes rapid release, we might need to change this :P + is_built emacs 100 >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status == 1 ]] + empty $tmpdir/stdout + empty $tmpdir/stderr +} + +it_returns_0_for_past_packages() { + # If emacs ever goes rapid release, we might need to change this :P + is_built emacs 1 >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stdout + empty $tmpdir/stderr +} diff --git a/test/cases/lib-blacklist.bats b/test/cases/lib-blacklist.bats new file mode 100644 index 0000000..32d700d --- /dev/null +++ b/test/cases/lib-blacklist.bats @@ -0,0 +1,135 @@ +#!/usr/bin/env roundup + +describe libreblacklist +. ./test-common.sh + +it_works_with_just_pkgname() { + v="$(libreblacklist normalize <<> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot + BLACKLIST='phony://example.com' + eot + + libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_cat_with_no_blacklist_or_network() { + cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot + BLACKLIST='phony://example.com' + eot + + libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_update_when_BLACKLIST_is_unset() { + cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot + BLACKLIST= + eot + + libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_cat_when_syntax_error_in_conf() { + # there is a stray single quote in there + 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=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_downloads_the_blacklist_as_needed() { + require network || return 0 + + libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr + + not empty $tmpdir/stdout +} + +it_downloads_the_blacklist_repeatedly() { + require network || return 0 + + libreblacklist update + libreblacklist update +} + +it_displays_help_and_fails_with_no_args() { + LC_ALL=C libreblacklist >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + [[ "$(sed 1q $tmpdir/stderr)" =~ 'Usage: libreblacklist ' ]] +} + +it_displays_help_when_given_h() { + LC_ALL=C libreblacklist -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ 'Usage: libreblacklist ' ]] + empty $tmpdir/stderr +} + +it_displays_help_when_given_h_cat() { + LC_ALL=C libreblacklist -h cat >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" == 'Usage: libreblacklist cat' ]] + empty $tmpdir/stderr +} diff --git a/test/cases/lib-conf.bats b/test/cases/lib-conf.bats new file mode 100644 index 0000000..cf0b805 --- /dev/null +++ b/test/cases/lib-conf.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env roundup + +describe lib/conf.sh +. ./test-common.sh + +it_sets_makepkg_vars_in_custom_file() { + unset PKGDEST + touch "$tmpdir/makepkg.conf" + bash -c "$(printf '. $(librelib conf.sh); MAKEPKG_CONF=%q set_var makepkg PKGDEST /pkgdest' "$tmpdir/makepkg.conf")" + . "$tmpdir/makepkg.conf" + [[ $PKGDEST == /pkgdest ]] +} + +it_figures_out_HOME_when_root() { + require sudo || return 0 + # This one is tricky, because it does the job too well, it will find + # the actual HOME, instead of the test environment HOME. Therefore, we + # will just check that [[ $HOME != /root ]] + cd "$tmpdir" + echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh + LIBREHOME=$(testsudo bash ./test.sh) + [[ $LIBREHOME != /root ]] +} + +it_nests_LIBREUSER() { + require sudo || return 0 + [[ $USER != root ]] + cd "$tmpdir" + echo '. $(librelib conf.sh); echo "$LIBREUSER"' > test.sh + + LIBREUSER=$(testsudo bash ./test.sh) + [[ $LIBREUSER == "$USER" ]] + + LIBREUSER=$(testsudo testsudo -u "$USER" bash ./test.sh) + [[ $LIBREUSER == "$USER" ]] +} + +it_respects_custom_HOME() { + cd "$tmpdir" + echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh + + export HOME=/foo + LIBREHOME=$(bash ./test.sh) + + [[ $LIBREHOME == /foo ]] +} diff --git a/test/cases/lib-messages.bats b/test/cases/lib-messages.bats new file mode 100644 index 0000000..d0b4497 --- /dev/null +++ b/test/cases/lib-messages.bats @@ -0,0 +1,63 @@ +#!/usr/bin/env roundup + +describe libremessages +. ./test-common.sh + +it_can_be_included_twice() ( + . libremessages + . libremessages +) + +it_can_be_included_with_set_euE() ( + set -euE + . libremessages +) + +it_works_with_no_color_and_set_euE() { + ( + unset TERM + set -euE + . libremessages + msg Foo + ) >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_can_be_called_without_including() { + libremessages msg Foo >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_with_msg_and_no_args() { + libremessages msg || status=$? + [[ $status != 0 ]] +} + +it_allows_subheadings_to_flag() { + # Note that old versions of `flag` panicked if given an odd + # number of headings, so give an odd number here. + libremessages flag \ + -a adesc \ + -b bdesc \ + Head1: \ + -c cdesc > $tmpdir/out + cat > $tmpdir/exp <<-eot + -a adesc + -b bdesc + Head1: + -c cdesc + eot + diff -u $tmpdir/exp $tmpdir/out +} + +it_is_quiet_on_stdout_on_errs() { + LC_ALL=C bash -euE -c '. libremessages; setup_traps; false' >"$tmpdir/stdout" 2>"$tmpdir/stderr" || status=$? + + [[ $status != 0 ]] + empty "$tmpdir/stdout" + grep '==> ERROR:' "$tmpdir/stderr" +} diff --git a/test/cases/librechroot.bats b/test/cases/librechroot.bats new file mode 100644 index 0000000..e476f6f --- /dev/null +++ b/test/cases/librechroot.bats @@ -0,0 +1,192 @@ +#!/usr/bin/env roundup + +describe librechroot +. ./test-common.sh + +it_creates_repo_for_new_chroots() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db +} + +it_cleans_the_local_repo_correctly() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$roundup_test_name" make + testsudo librechroot -l "$roundup_test_name" clean-repo + testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db + # TODO: inspect /repo/* more +} + +it_respects_exit_status_if_out_isnt_a_tty() ( + require network sudo || return 0 + set -o pipefail + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + { testsudo librechroot -l "$roundup_test_name" run bash -c 'exit 3' | cat; } || status=$? + + [[ $status == 3 ]] +) + +it_creates_ca_certificates() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$roundup_test_name" run test -r /etc/ssl/certs/ca-certificates.crt +} + +it_disables_networking_when_requested() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + + testsudo librechroot -l "$roundup_test_name" run curl https://repo.parabola.nu/ >/dev/null + not testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabola.nu/ >/dev/null +} + +it_handles_CHROOTEXTRAPKG_correctly() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + + not testsudo librechroot -l "$roundup_test_name" run lsof + echo "CHROOTEXTRAPKG=(lsof)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf + testsudo librechroot -l "$roundup_test_name" install-name lsof + testsudo librechroot -l "$roundup_test_name" clean-pkgs + testsudo librechroot -l "$roundup_test_name" run lsof + echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf + testsudo librechroot -l "$roundup_test_name" clean-pkgs + not testsudo librechroot -l "$roundup_test_name" run lsof +} + +it_obeys_depends_in_PKGBUILD() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + + # Make sure it's not in the base install + not testsudo librechroot -l "$roundup_test_name" run lsof + # Make sure it removes it without the PKGBUILD + testsudo librechroot -l "$roundup_test_name" install-name lsof + testsudo librechroot -l "$roundup_test_name" run lsof + testsudo librechroot -l "$roundup_test_name" clean-pkgs + not testsudo librechroot -l "$roundup_test_name" run lsof + # Make sure it leaves it with the PKGBUILD + testsudo librechroot -l "$roundup_test_name" install-name lsof + testsudo librechroot -l "$roundup_test_name" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat librechroot.d/PKGBUILD-arches)" + # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. + # https://bugs.archlinux.org/task/56828 + testsudo librechroot -l "$roundup_test_name" run chown -R 99:99 /startdir + testsudo librechroot -l "$roundup_test_name" clean-pkgs + testsudo librechroot -l "$roundup_test_name" run lsof +} + +it_can_install_libretools_with_chcleanup() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + + not testsudo librechroot -l "$roundup_test_name" run test -f /usr/bin/chcleanup + testsudo librechroot -l "$roundup_test_name" run mkdir /startdir + testsudo librechroot -l "$roundup_test_name" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat librechroot.d/PKGBUILD-libretools)" + # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. + # https://bugs.archlinux.org/task/56828 + testsudo librechroot -l "$roundup_test_name" run chown -R 99:99 /startdir + testsudo librechroot -l "$roundup_test_name" clean-pkgs + testsudo librechroot -l "$roundup_test_name" run test -f /usr/bin/chcleanup +} + +it_displays_help_as_normal_user() { + rm -rf "$XDG_CONFIG_HOME" + LC_ALL=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_otherwise_fails_as_normal_user() { + librechroot -l "$roundup_test_name" run true >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_displays_help_and_fails_with_0_args() { + LC_ALL=C librechroot -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + [[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]] +} + +it_obeys_the_n_flag() { + require network sudo || return 0 + + not test -f "$chrootdir/$roundup_test_name/$roundup_test_name/$roundup_test_name.stamp" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -n "$roundup_test_name" -l "$roundup_test_name" run touch /"$roundup_test_name.stamp" + + test -f "$chrootdir/$roundup_test_name/$roundup_test_name/$roundup_test_name.stamp" +} + +# requires sudo so we know it's not failing because it needs root +it_fails_for_unknown_commands() { + require sudo || return 0 + testsudo librechroot phony >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +# requires sudo so we know it's not failing because it needs root +it_fails_for_unknown_flags() { + require sudo || return 0 + testsudo librechroot -q >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_when_syncing_a_copy_with_itself() { + require sudo || return 0 + testsudo timeout 5 librechroot -l root sync || status=$? + case $status in + 0|124|137) # success|timeout+TERM|timeout+KILL + false;; + *) + true;; + esac +} + +it_deletes_copies() { + require network sudo || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$roundup_test_name" make + test -d "$chrootdir/default/$roundup_test_name" + testsudo librechroot -l "$roundup_test_name" delete + not test -e "$chrootdir/default/$roundup_test_name" +} + +it_deletes_subvolumes_recursively() { + require network sudo btrfs || return 0 + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$roundup_test_name" make + testsudo librechroot -l "$roundup_test_name" install-name btrfs-progs + test -d "$chrootdir/default/$roundup_test_name" + not test -e "$chrootdir/default/$roundup_test_name/var/subvolume" + testsudo librechroot -l "$roundup_test_name" run btrfs subvolume create /var/subvolume + test -d "$chrootdir/default/$roundup_test_name/var/subvolume" + testsudo librechroot -l "$roundup_test_name" delete + not test -e "$chrootdir/default/$roundup_test_name" +} + +it_cleans_up_TMPDIR() { + require network sudo || return 0 + + local dir="$tmpdir/tmp" + mkdir -- "$dir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + TMPDIR=$dir testsudo librechroot -l "$roundup_test_name" -A x86_64 make + + # Make sure $dir is now empty + rmdir -- "$dir" +} diff --git a/test/cases/libredbdiff.bats b/test/cases/libredbdiff.bats new file mode 100644 index 0000000..6cebbf6 --- /dev/null +++ b/test/cases/libredbdiff.bats @@ -0,0 +1,50 @@ +#!/usr/bin/env roundup + +describe libredbdiff +. ./test-common.sh + +before() { + common_before + + install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libredbdiff.conf" <<-'eot' + statedir="$PWD" + mirror_prbl='https://repo.parabola.nu/$repo/os/$arch' + mirror_arch='https://mirrors.kernel.org/archlinux/$repo/os/$arch' + repos=(libre) + eot +} + +it_displays_help() { + LC_ALL=C libredbdiff -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_handles_packages_with_multiple_provides_explicit() { + cd libredbdiff.d/statedir + + libredbdiff -n libre >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stderr + diff -w ../expected-explicit.txt $tmpdir/stdout +} + +it_handles_packages_with_multiple_provides_implicit() { + cd libredbdiff.d/statedir + + libredbdiff -n >$tmpdir/stdout 2>$tmpdir/stderr + + empty $tmpdir/stderr + diff -w ../expected-implicit.txt $tmpdir/stdout +} + +it_fails_on_bad_repo_args() { + cd libredbdiff.d/statedir + + libredbdiff -n bogus >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} diff --git a/test/cases/librefetch.bats b/test/cases/librefetch.bats new file mode 100644 index 0000000..9edc227 --- /dev/null +++ b/test/cases/librefetch.bats @@ -0,0 +1,135 @@ +#!/usr/bin/env roundup + +describe librefetch +. ./test-common.sh + +before() { + common_before + + 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="" + source ${_librelib_conf_sh_sysconfdir@Q}/makepkg.d/librefetch.conf + eot + export MAKEPKG_CONF="$XDG_CONFIG_HOME/pacman/makepkg.conf" + + install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/librefetch.conf" <<-eot + MIRRORS=("phony://example.com/dir/") + DOWNLOADER=/usr/bin/false + eot +} + +it_displays_help() { + LC_ALL=C librefetch -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_fails_with_bad_flags() { + local srcball=testpkg-1.0.tar.gz + cp librefetch.d/* "$tmpdir/" + cd "$tmpdir" + mv PKGBUILD{-mksource,} + + librefetch --bogus-flag libre://"$srcball" >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr + not test -e $tmpdir/workdir/srcdest/$srcball +} + +# This test used to be called "it_cleans_src_libre_first", but let's +# be honest: it checks pretty much everything related to normal +# operation. +it_runs_with_mksource() { + local srcball=testpkg-1.0.tar.gz + cp librefetch.d/* "$tmpdir/" + cd "$tmpdir" + mv PKGBUILD{-mksource,} + + # Create garbage, to verifiy that it cleans src-libre first + mkdir -p src-libre/foo + touch src-libre/foo/file + + # Run librefetch + makepkg -g >& log.txt + + # Verify that no temporary files were left around + not test -e librefetch.* + + # Verify that there were no warnings about missing backup=() + # files + not grep -F etc/testpkg.conf log.txt + + # Verify: + # - The srcball was created... + # - ... and is in the correct directory + # - The srcball does not contain the garbage created earlier + # - The files in the srcball are in the correct order (if the + # order isn't ensured, then this would only sometimes fail, + # unfortunately). + bsdtar tf "$tmpdir/workdir/srcdest/$srcball" > list-pkg.txt + diff -u list.txt list-pkg.txt + # Verify that the signature was created and matches + gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null +} + +it_runs_with_srcbuild() { + local srcball=testpkg-1.0.tar.gz + cp librefetch.d/* "$tmpdir/" + cd "$tmpdir" + mv PKGBUILD{-srcbuild,} + mv SRCBUILD{-srcbuild,} + + # Create garbage, to verifiy that it cleans src-libre first + mkdir -p src-libre/foo + touch src-libre/foo/file + + # Run librefetch + makepkg -g + + # Verify that no temporary files were left around + not test -e librefetch.* + + # Verify: + # - The srcball was created... + # - ... and is in the correct directory + # - The srcball does not contain the garbage created earlier + # - The files in the srcball are in the correct order (if the + # order isn't ensured, then this would only sometimes fail, + # unfortunately). + bsdtar tf "$tmpdir/workdir/srcdest/$srcball" > list-pkg.txt + diff -u list.txt list-pkg.txt + # Verify that the signature was created and matches + gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null +} + +it_recurses() { + local srcball=testpkg-1.0.tar.gz + cp librefetch.d/* "$tmpdir/" + cd "$tmpdir" + mv PKGBUILD{-recurse,} + + makepkg -g + bsdtar tf "$tmpdir/workdir/srcdest/$srcball" > list-pkg.txt + diff -u list.txt list-pkg.txt + gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null +} + +it_doesnt_recurse_extra() { + local srcball=testpkg-1.0.tar.gz + cp librefetch.d/* "$tmpdir/" + cd "$tmpdir" + mv PKGBUILD{-recurse,} + + :> "$tmpdir/workdir/srcdest/$srcball" + makepkg -g + empty "$tmpdir/workdir/srcdest/$srcball" + gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null +} diff --git a/test/cases/librelib.bats b/test/cases/librelib.bats new file mode 100644 index 0000000..ebaf7b2 --- /dev/null +++ b/test/cases/librelib.bats @@ -0,0 +1,63 @@ +#!/usr/bin/env roundup + +describe librelib +. ./test-common.sh + +it_displays_help_and_fails_with_0_args() { + librelib >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + empty $tmpdir/stdout + [[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]] + [[ $status != 0 ]] +} + +it_fails_with_2_args() { + librelib a b >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status != 0 ]] +} + +it_displays_usage_text() { + librelib -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +# Nothing in $(libdir) should be executable anymore (except that +# $(libexecdir)=$(libdir), and executable things go in there. But I +# digress, libremessages should not be executable anymore). +it_finds_messages() { + v1=$(librelib messages) + v2=$(librelib libremessages) + v3=$(librelib messages.sh) + v4=$(librelib libremessages.sh) + + [[ -r "$v1" && ! -x "$v1" ]] + [[ "$v1" == "$v2" ]] + [[ "$v1" == "$v3" ]] + [[ "$v1" == "$v4" ]] +} + +# conf.sh is non-executable +it_finds_conf() { + v1=$(librelib conf) + v2=$(librelib libreconf) + v3=$(librelib conf.sh) + v4=$(librelib libreconf.sh) + + [[ -r "$v1" && ! -x "$v1" ]] + [[ "$v1" == "$v2" ]] + [[ "$v1" == "$v3" ]] + [[ "$v1" == "$v4" ]] +} + +it_fails_to_find_phony() { + librelib phony >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status != 0 ]] +} diff --git a/test/cases/libremakepkg.bats b/test/cases/libremakepkg.bats new file mode 100644 index 0000000..36176d3 --- /dev/null +++ b/test/cases/libremakepkg.bats @@ -0,0 +1,240 @@ +#!/usr/bin/env roundup + +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" + cd "$tmpdir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo libremakepkg -l "$roundup_test_name" + + globfile libretools-hello-1.0-1-any.pkg.tar.?z +} + +it_disables_networking_during_prepare() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-netprepare "$tmpdir/PKGBUILD" + cd "$tmpdir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + not testsudo libremakepkg -l "$roundup_test_name" + not globfile libretools-netprepare-1.0-1-any.pkg.tar.?z + testsudo libremakepkg -l "$roundup_test_name" -N + globfile libretools-netprepare-1.0-1-any.pkg.tar.?z +} + +it_disables_networking_during_build() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-netbuild "$tmpdir/PKGBUILD" + cd "$tmpdir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + not testsudo libremakepkg -l "$roundup_test_name" + not globfile libretools-netbuild-1.0-1-any.pkg.tar.?z + testsudo libremakepkg -l "$roundup_test_name" -N + globfile libretools-netbuild-1.0-1-any.pkg.tar.?z +} + +it_disables_networking_during_package() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-netpackage "$tmpdir/PKGBUILD" + cd "$tmpdir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + not testsudo libremakepkg -l "$roundup_test_name" + not globfile libretools-netpackage-1.0-1-any.pkg.tar.?z + testsudo libremakepkg -l "$roundup_test_name" -N + globfile libretools-netpackage-1.0-1-any.pkg.tar.?z +} + +it_cleans_the_chroot_before_building() { + require network sudo || return 0 + # 1. First, we build testpkg1 + # 2. Then, we build testpkg2, which depends on testpkg1 + # Therefore, testpkg1 will be installed after testpkg2 is built, we + # check for that. + # 3. Then, we build hello, which depends on neither, so testpkg1 should + # be removed. + + # Also, do funny things with the output of libremakepkg to get a helpful + # fail case. + + mkdir -p "$tmpdir"/{1,2,3} + cp libremakepkg.d/PKGBUILD-testpkg1 "$tmpdir/1/PKGBUILD" + cp libremakepkg.d/PKGBUILD-testpkg2 "$tmpdir/2/PKGBUILD" + cp libremakepkg.d/PKGBUILD-hello "$tmpdir/3/PKGBUILD" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + + cd "$tmpdir/1" + testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } + + cd "$tmpdir/2" + testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } + testsudo librechroot -l "$roundup_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() { + not testsudo librechroot -l "$roundup_test_name" run test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar.?z + + cd "$tmpdir/3" + testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } + not testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail' +} + +it_handles_PKGDEST_not_existing() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo env PKGDEST="$tmpdir/dest/pkgdest" libremakepkg -l "$roundup_test_name" + + globfile dest/pkgdest/libretools-hello-1.0-1-any.pkg.tar.?z +} + +it_displays_help_as_normal_user() { + rm -rf "$XDG_CONFIG_HOME" + LC_ALL=C libremakepkg -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_otherwise_fails_as_normal_user() { + # I do this to give it a chance of passing + cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + libremakepkg >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_if_a_hook_fails() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot + BLACKLIST='phony://example.com' + eot + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + tail -n1 $tmpdir/stderr | grep -qF '==> ERROR: Failure(s) in check_pkgbuild: check_pkgbuild_nonfree' +} + +it_detects_distcc_files() { + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + cat >> "$XDG_CONFIG_HOME/libretools/chroot.conf" <<-eot + CHROOTEXTRAPKG+=(distcc-nozeroconf socat) + eot + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$roundup_test_name" install-name distcc-nozeroconf socat + + # first make sure that the engine works + testsudo libremakepkg -l "$roundup_test_name" + globfile libretools-hello-1.0-1-any.pkg.tar.?z + rm -f -- libretools-hello-1.0-1-any.pkg.tar.?z + # now throw a wrench in it + testsudo librechroot -l "$roundup_test_name" run touch /bin/distcc-tool + # and make sure that the engine broke + testsudo libremakepkg -l "$roundup_test_name" || status=$? + [[ $status != 0 ]] + not globfile libretools-hello-1.0-1-any.pkg.tar.?z +} + +it_allows_distcc_on_long_chrootpaths() { + # The maximum AF_UNIX socket path is 108 bytes; so let's have + # a chroot name that's guaranteed to be >110 characters. + local chrootname=$roundup_test_name.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + + require network sudo || return 0 + cp libremakepkg.d/PKGBUILD-distcc "$tmpdir/PKGBUILD" + cd "$tmpdir" + + cat >> "$XDG_CONFIG_HOME/libretools/chroot.conf" <<-eot + CHROOTEXTRAPKG+=(distcc-nozeroconf socat) + eot + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo librechroot -l "$chrootname" install-name distcc-nozeroconf socat + testsudo libremakepkg -l "$chrootname" + globfile libretools-distcc-1.0-1-any.pkg.tar.?z +} + +it_doesnt_symlink_outputs() { + require network sudo || return 0 + + sed -i /^unset/d "$XDG_CONFIG_HOME/pacman/makepkg.conf" + + cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo libremakepkg -l "$roundup_test_name" + + not stat libretools-hello-1.0-1-any.pkg.tar.?z + not stat libretools-hello-1.0-1-any.src.tar.?z + globfile "$tmpdir/workdir/pkgdest"/libretools-hello-1.0-1-any.pkg.tar.?z + globfile "$tmpdir/workdir/srcpkgdest"/libretools-hello-1.0-1-any.src.tar.?z +} + +it_succeeds_with_good_signatures() { + require network sudo || return 0 + + cp libremakepkg.d/PKGBUILD-signed "$tmpdir/PKGBUILD" + cp libremakepkg.d/hello.sh "$tmpdir/hello.sh" + cd "$tmpdir" + gpg --detach-sign --use-agent --no-armor hello.sh + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo libremakepkg -l "$roundup_test_name" +} + +it_fails_with_bad_signatures() { + require network sudo || return 0 + + cp libremakepkg.d/PKGBUILD-signed "$tmpdir/PKGBUILD" + cp libremakepkg.d/hello.sh "$tmpdir/hello.sh" + cd "$tmpdir" + gpg --detach-sign --use-agent --no-armor hello.sh + echo 'echo pwned' >> hello.sh + makepkg -g >> PKGBUILD + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + not testsudo libremakepkg -l "$roundup_test_name" +} + +it_does_not_run_pkgver() { + require network sudo || return 0 + + cp libremakepkg.d/PKGBUILD-pkgver "$tmpdir/PKGBUILD" + pushd "$tmpdir" + + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo libremakepkg -l "$roundup_test_name" + + globfile libretools-pkgver-1-1-any.pkg.tar.?z + not globfile libretools-pkgver-2-1-any.pkg.tar.?z + popd + diff -u libremakepkg.d/PKGBUILD-pkgver "$tmpdir/PKGBUILD" +} diff --git a/test/cases/librerelease.bats b/test/cases/librerelease.bats new file mode 100644 index 0000000..5ffbb14 --- /dev/null +++ b/test/cases/librerelease.bats @@ -0,0 +1,53 @@ +#!/usr/bin/env roundup + +describe librerelease +. ./test-common.sh + +it_displays_usage_text() { + rm -rf "$XDG_CONFIG_HOME" + LC_ALL=C librerelease -h >"$tmpdir/stdout" 2>"$tmpdir/stderr" + + [[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]] + empty "$tmpdir/stderr" +} + +it_lists_all_files() { + WORKDIR="$tmpdir/workdir" + mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2/sub" + touch \ + "$WORKDIR/staging/repo1/file1" \ + "$WORKDIR/staging/repo1/file2" \ + "$WORKDIR/staging/repo2/file with spaces" \ + "$WORKDIR/staging/repo2/sub/subfolder" + unset WORKDIR + LC_ALL=C librerelease -l &>"$tmpdir/list" || { status=$?; cat "$tmpdir/list"; return $status; } + + cat > "$tmpdir/list-correct" <<-eot + -> repo1 + file1 + file2 + -> repo2 + file with spaces + sub/subfolder + eot + + diff "$tmpdir/list-correct" "$tmpdir/list" +} + +it_fails_if_gpgkey_not_set() { + unset GPGKEY + + WORKDIR="$tmpdir/workdir" + mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2/sub" + touch \ + "$WORKDIR/staging/repo1/file1" \ + "$WORKDIR/staging/repo1/file2" \ + "$WORKDIR/staging/repo2/file with spaces" \ + "$WORKDIR/staging/repo2/sub/subfolder" + unset WORKDIR + LC_ALL=C librerelease -l >"$tmpdir/stdout" 2>"$tmpdir/stderr" || status=$? + + [[ $status != 0 ]] + empty "$tmpdir/stdout" + grep GPGKEY "$tmpdir/stderr" +} diff --git a/test/cases/librestage.bats b/test/cases/librestage.bats new file mode 100644 index 0000000..2fe3415 --- /dev/null +++ b/test/cases/librestage.bats @@ -0,0 +1,71 @@ +#!/usr/bin/env roundup + +describe librestage +. ./test-common.sh + +it_displays_usage_text() { + rm -rf "$XDG_CONFIG_HOME" + LC_ALL=C librestage -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]] + empty "$tmpdir/stderr" +} + +it_fails_with_0_args() { + librestage >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty "$tmpdir/stdout" + not empty "$tmpdir/stderr" +} + +it_fails_with_invalid_args() { + librestage -q >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty "$tmpdir/stdout" + not empty "$tmpdir/stderr" +} + +it_guesses_the_repo() { + nochroot=false; require network sudo || nochroot=true + mkdir -p -- "$tmpdir/reponame/libretools-hello" + cp librestage.d/PKGBUILD-hello "$tmpdir/reponame/libretools-hello/PKGBUILD" + cd "$tmpdir/reponame/libretools-hello" + + if $nochroot; then + makepkg + else + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo libremakepkg -l "$roundup_test_name" + fi + librestage + + find "$tmpdir" -not -type d -exec ls -ld -- {} + + globfile $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar.?z + $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z +} + +it_stages_packages_without_PKGDEST() { + nochroot=false; require network sudo || nochroot=true + + cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot + PKGDEST='' + SRCPKGDEST='' + eot + + cp librestage.d/PKGBUILD-hello "$tmpdir/PKGBUILD" + cd "$tmpdir" + + if $nochroot; then + makepkg + else + libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty + testsudo libremakepkg -l "$roundup_test_name" + fi + librestage repo1 + + find "$tmpdir" -not -type d -exec ls -ld -- {} + + globfile $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.?z + $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z +} diff --git a/test/cases/librexgettext.bats b/test/cases/librexgettext.bats new file mode 100644 index 0000000..d4c8028 --- /dev/null +++ b/test/cases/librexgettext.bats @@ -0,0 +1,58 @@ +#!/usr/bin/env roundup + +describe librexgettext +. ./test-common.sh + +it_displays_help() { + LC_ALL=C librexgettext -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_fails_with_0_args() { + librexgettext >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +passcase() { + librexgettext librexgettext.d/$roundup_test_name.sh > $tmpdir/actual.pot 2>$tmpdir/stderr + empty $tmpdir/stderr + diff -u librexgettext.d/$roundup_test_name.pot $tmpdir/actual.pot +} + +it_handles_multiple_skipped_flags() { passcase; } +it_handles_zero_flags() { passcase; } +it_handles_librefetch_flags() { passcase; } + +it_fails_on_missing_final_flag_description() { + librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4:"* ]] +} + + +it_fails_on_subshell_flag_descriptions() { + librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4-6:"* ]] +} + +it_doesnt_keep_failing() { + librexgettext some_file_that_doesnt_exist >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + [[ $status != 0 ]] + empty $tmpdir/stdout + [[ "$(wc -l <$tmpdir/stderr)" == 1 ]] +} + +it_handles_multiple_files() { + librexgettext librexgettext.d/combine1.sh librexgettext.d/combine2.sh > $tmpdir/actual.pot 2>$tmpdir/stderr + empty $tmpdir/stderr + diff -u librexgettext.d/combine.pot $tmpdir/actual.pot +} diff --git a/test/cases/pkgbuild-check-nonfree.bats b/test/cases/pkgbuild-check-nonfree.bats new file mode 100644 index 0000000..0582e29 --- /dev/null +++ b/test/cases/pkgbuild-check-nonfree.bats @@ -0,0 +1,68 @@ +#!/usr/bin/env roundup + +describe pkgbuild-check-nonfree +. ./test-common.sh + +before() { + common_before + + # 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 + eot +} + +it_displays_usage_text() { + # This test seems silly, but it makes sure that it is executable, + # syntactically correct, and loading libraries works. + LC_ALL=C pkgbuild-check-nonfree -h >$tmpdir/stdout 2>$tmpdir/stderr + status=$? + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr + [[ $status == 0 ]] +} + +it_succeeds_for_free_depends() { + pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == 0 ]] +} + +it_succeeds_for_nonfree_depend_with_replacement() { + pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status == 0 ]] +} + +it_fails_for_nonfree_depend() { + pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr + + local pcn_stat=$status + + pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + [[ $status != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +it_fails_when_there_is_no_blacklist() { + rm $XDG_CACHE_HOME/libretools/blacklist.txt + + pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || status=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $status != 0 ]] && [[ $status != 15 ]] +} diff --git a/test/cases/toru-path.bats b/test/cases/toru-path.bats new file mode 100644 index 0000000..5576ad7 --- /dev/null +++ b/test/cases/toru-path.bats @@ -0,0 +1,56 @@ +#!/usr/bin/env roundup + +describe toru-path +. ./test-common.sh + +it_displays_help() { + LC_ALL=C toru-path -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_runs() { + cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot + TORUPATH=${tmpdir@Q} + REPOS=(libre) + eot + cat >> "$HOME/.abs.conf" <<-eot + ABSROOT=${PWD@Q}/toru.d + eot + + toru-path + + tcamgr list "$tmpdir/paths.tch"|LC_COLLATE=C sort|while read -r key; do + val="$(tcamgr get "$tmpdir/paths.tch" "$key")" + printf '«%q» -> «%q»\n' "$key" "$val" + done > "$tmpdir/paths-actual.txt" + + printf '«%q» -> «%q»\n' \ + BAR "$PWD/toru.d/libre/split-base" \ + BAZ "$PWD/toru.d/libre/split-base" \ + FOO "$PWD/toru.d/libre/split-base" \ + bar "$PWD/toru.d/libre/split" \ + baz "$PWD/toru.d/libre/split" \ + foo "$PWD/toru.d/libre/split" \ + simple "$PWD/toru.d/libre/simple" \ + split-base "$PWD/toru.d/libre/split-base" \ + > "$tmpdir/paths-expected.txt" + + diff "$tmpdir/paths-expected.txt" "$tmpdir/paths-actual.txt" +} + +it_sets_torupath() { + cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot + TORUPATH=${tmpdir@Q} + REPOS=(libre) + eot + cat >> "$HOME/.abs.conf" <<-eot + ABSROOT=${PWD@Q}/toru.d + eot + + mkdir -p "$tmpdir/x" + T="$tmpdir/x" toru-path + test -f "$tmpdir/x/paths.tch" + not test -e "$tmpdir/paths.tch" +} diff --git a/test/fixtures/librechroot/PKGBUILD-arches b/test/fixtures/librechroot/PKGBUILD-arches new file mode 100644 index 0000000..6116ad9 --- /dev/null +++ b/test/fixtures/librechroot/PKGBUILD-arches @@ -0,0 +1,22 @@ +pkgname='libretools-hello' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(i686 x86_64) +depends=(sh) +depends_i686=('lsof') +depends_x86_64=('lsof') + +build() { + cd "$srcdir" + echo '#!/bin/sh' > hello.sh + echo 'echo Hello, world!' >> hello.sh + echo 'lsof' >> hello.sh +} + +package() { + cd "$srcdir" + install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello +} diff --git a/test/fixtures/librechroot/PKGBUILD-libretools b/test/fixtures/librechroot/PKGBUILD-libretools new file mode 100644 index 0000000..dcc0f61 --- /dev/null +++ b/test/fixtures/librechroot/PKGBUILD-libretools @@ -0,0 +1,20 @@ +pkgname='libretools-hello' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) +depends=(libretools) + +build() { + cd "$srcdir" + echo '#!/bin/sh' > hello.sh + echo 'echo Hello, world!' >> hello.sh + echo 'lsof' >> hello.sh +} + +package() { + cd "$srcdir" + install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello +} diff --git a/test/fixtures/libredbdiff/expected-explicit.txt b/test/fixtures/libredbdiff/expected-explicit.txt new file mode 100644 index 0000000..8fb89bf --- /dev/null +++ b/test/fixtures/libredbdiff/expected-explicit.txt @@ -0,0 +1 @@ +p linux-libre linux 4.10.12_gnu-2 | 4.10.13-1 diff --git a/test/fixtures/libredbdiff/expected-implicit.txt b/test/fixtures/libredbdiff/expected-implicit.txt new file mode 100644 index 0000000..afc2689 --- /dev/null +++ b/test/fixtures/libredbdiff/expected-implicit.txt @@ -0,0 +1,2 @@ +[libre] +p linux-libre linux 4.10.12_gnu-2 | 4.10.13-1 diff --git a/test/fixtures/libredbdiff/statedir/pacman.archlinux/local/ALPM_DB_VERSION b/test/fixtures/libredbdiff/statedir/pacman.archlinux/local/ALPM_DB_VERSION new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/test/fixtures/libredbdiff/statedir/pacman.archlinux/local/ALPM_DB_VERSION @@ -0,0 +1 @@ +9 diff --git a/test/fixtures/libredbdiff/statedir/pacman.archlinux/sync/core.db b/test/fixtures/libredbdiff/statedir/pacman.archlinux/sync/core.db new file mode 100644 index 0000000..b0f737b Binary files /dev/null and b/test/fixtures/libredbdiff/statedir/pacman.archlinux/sync/core.db differ diff --git a/test/fixtures/libredbdiff/statedir/pacman.conf.archlinux b/test/fixtures/libredbdiff/statedir/pacman.conf.archlinux new file mode 100644 index 0000000..d4a9c8d --- /dev/null +++ b/test/fixtures/libredbdiff/statedir/pacman.conf.archlinux @@ -0,0 +1,6 @@ +[options] +DBPath = ./pacman.archlinux +Architecture = x86_64 + +[core] +Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch diff --git a/test/fixtures/libredbdiff/statedir/pacman.conf.parabola b/test/fixtures/libredbdiff/statedir/pacman.conf.parabola new file mode 100644 index 0000000..7b553dd --- /dev/null +++ b/test/fixtures/libredbdiff/statedir/pacman.conf.parabola @@ -0,0 +1,6 @@ +[options] +DBPath = ./pacman.parabola +Architecture = x86_64 + +[libre] +Server = https://repomirror.parabola.nu/$repo/os/$arch diff --git a/test/fixtures/libredbdiff/statedir/pacman.parabola/local/ALPM_DB_VERSION b/test/fixtures/libredbdiff/statedir/pacman.parabola/local/ALPM_DB_VERSION new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/test/fixtures/libredbdiff/statedir/pacman.parabola/local/ALPM_DB_VERSION @@ -0,0 +1 @@ +9 diff --git a/test/fixtures/libredbdiff/statedir/pacman.parabola/sync/libre.db b/test/fixtures/libredbdiff/statedir/pacman.parabola/sync/libre.db new file mode 100644 index 0000000..1bd5065 Binary files /dev/null and b/test/fixtures/libredbdiff/statedir/pacman.parabola/sync/libre.db differ diff --git a/test/fixtures/librefetch/PKGBUILD-mksource b/test/fixtures/librefetch/PKGBUILD-mksource new file mode 100644 index 0000000..74489de --- /dev/null +++ b/test/fixtures/librefetch/PKGBUILD-mksource @@ -0,0 +1,19 @@ +pkgname=testpkg +pkgver=1.0 +pkgrel=1 +pkgdesc=foo +arch=(any) +source=("libre://$pkgname-$pkgver.tar.gz"{,.sig}) +backup=(etc/testpkg.conf) + +mksource() { + mkdir "$srcdir/bar" + local file + for file in '~foo' '~a' a A; do + touch "$srcdir/bar/$file" + done +} + +package() { + :; +} diff --git a/test/fixtures/librefetch/PKGBUILD-recurse b/test/fixtures/librefetch/PKGBUILD-recurse new file mode 100644 index 0000000..fad5976 --- /dev/null +++ b/test/fixtures/librefetch/PKGBUILD-recurse @@ -0,0 +1,18 @@ +pkgname=testpkg +pkgver=1.0 +pkgrel=1 +pkgdesc=foo +arch=(any) +source=("libre://$pkgname-$pkgver.tar.gz.sig") + +mksource() { + mkdir "$srcdir/bar" + local file + for file in '~foo' '~a' a A; do + touch "$srcdir/bar/$file" + done +} + +package() { + :; +} diff --git a/test/fixtures/librefetch/PKGBUILD-srcbuild b/test/fixtures/librefetch/PKGBUILD-srcbuild new file mode 100644 index 0000000..40c5c79 --- /dev/null +++ b/test/fixtures/librefetch/PKGBUILD-srcbuild @@ -0,0 +1,10 @@ +pkgname=testpkg +pkgver=1.0 +pkgrel=1 +pkgdesc=foo +arch=(any) +source=("libre://$pkgname-$pkgver.tar.gz"{,.sig}) + +package() { + :; +} diff --git a/test/fixtures/librefetch/SRCBUILD-srcbuild b/test/fixtures/librefetch/SRCBUILD-srcbuild new file mode 100644 index 0000000..6f172c5 --- /dev/null +++ b/test/fixtures/librefetch/SRCBUILD-srcbuild @@ -0,0 +1,21 @@ +pkgname=testpkg +pkgver=1.0 +pkgrel=1 +pkgdesc=foo +arch=(any) +source=() + +PKGDEST=$SRCDEST +PKGEXT=$SRCEXT + +build() { + mkdir "$srcdir/bar" + local file + for file in '~foo' '~a' a A; do + touch "$srcdir/bar/$file" + done +} + +package() { + cp -a -t "$pkgdir" "$srcdir"/* +} diff --git a/test/fixtures/librefetch/list.txt b/test/fixtures/librefetch/list.txt new file mode 100644 index 0000000..9bd32f4 --- /dev/null +++ b/test/fixtures/librefetch/list.txt @@ -0,0 +1,5 @@ +bar/ +bar/A +bar/a +bar/~a +bar/~foo diff --git a/test/fixtures/libremakepkg/PKGBUILD-distcc b/test/fixtures/libremakepkg/PKGBUILD-distcc new file mode 100644 index 0000000..5127ae6 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-distcc @@ -0,0 +1,23 @@ +pkgname='libretools-distcc' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) +depends=(sh) + +build() { + cd "$srcdir" + echo '#!/bin/sh' > hello.sh + echo 'echo Hello, world!' >> hello.sh + # I don't like hard-coding in an implementation detail, but + # this is the simplest way to verify that `distcc-tool + # odaemon` started correctly. + [[ -S /socket ]] +} + +package() { + cd "$srcdir" + install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-hello b/test/fixtures/libremakepkg/PKGBUILD-hello new file mode 100644 index 0000000..5f320fe --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-hello @@ -0,0 +1,19 @@ +pkgname='libretools-hello' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) +depends=(sh) + +build() { + cd "$srcdir" + echo '#!/bin/sh' > hello.sh + echo 'echo Hello, world!' >> hello.sh +} + +package() { + cd "$srcdir" + install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-netbuild b/test/fixtures/libremakepkg/PKGBUILD-netbuild new file mode 100644 index 0000000..4db1274 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-netbuild @@ -0,0 +1,17 @@ +pkgname='libretools-netbuild' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) + +build() { + cd "$srcdir" + curl https://repo.parabola.nu/ > index.html +} + +package() { + cd "$srcdir" + install -Dm644 index.html "$pkgdir"/usr/share/$pkgname/index.html +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-netpackage b/test/fixtures/libremakepkg/PKGBUILD-netpackage new file mode 100644 index 0000000..6cadcf8 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-netpackage @@ -0,0 +1,12 @@ +pkgname='libretools-netpackage' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) + +package() { + install -d "$pkgdir"/usr/share/$pkgname + curl https://repo.parabola.nu/ > "$pkgdir"/usr/share/$pkgname/index.html +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-netprepare b/test/fixtures/libremakepkg/PKGBUILD-netprepare new file mode 100644 index 0000000..efb7a43 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-netprepare @@ -0,0 +1,17 @@ +pkgname='libretools-netprepare' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) + +prepare() { + cd "$srcdir" + curl https://repo.parabola.nu/ > index.html +} + +package() { + cd "$srcdir" + install -Dm644 index.html "$pkgdir"/usr/share/$pkgname/index.html +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-pkgver b/test/fixtures/libremakepkg/PKGBUILD-pkgver new file mode 100644 index 0000000..6b92d84 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-pkgver @@ -0,0 +1,23 @@ +pkgname='libretools-pkgver' +pkgver=1 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) +depends=(sh) + +pkgver() { + echo 2 +} + +build() { + cd "$srcdir" + echo '#!/bin/sh' > hello.sh + echo 'echo Hello, world!' >> hello.sh +} + +package() { + cd "$srcdir" + install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-signed b/test/fixtures/libremakepkg/PKGBUILD-signed new file mode 100644 index 0000000..0979a85 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-signed @@ -0,0 +1,17 @@ +pkgname='libretools-signed' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +source=(hello.sh{,.sig}) +sha256sums=('1e70cef0dfe5ce1120ccde5e1551c7277bcddaa75a1808f49512f404e6b8aec8' + 'SKIP') + +pkgrel=1 +arch=(any) +depends=(sh) + +package() { + cd "$srcdir" + install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-testpkg1 b/test/fixtures/libremakepkg/PKGBUILD-testpkg1 new file mode 100644 index 0000000..8da1f14 --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-testpkg1 @@ -0,0 +1,19 @@ +pkgname='libretools-testpkg1' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) +depends=(sh) + +build() { + cd "$srcdir" + echo '#!/bin/sh' > testpkg1.sh + echo 'echo testpkg1' >> testpkg1.sh +} + +package() { + cd "$srcdir" + install -Dm755 testpkg1.sh "$pkgdir"/usr/bin/libretools-testpkg1 +} diff --git a/test/fixtures/libremakepkg/PKGBUILD-testpkg2 b/test/fixtures/libremakepkg/PKGBUILD-testpkg2 new file mode 100644 index 0000000..65d558e --- /dev/null +++ b/test/fixtures/libremakepkg/PKGBUILD-testpkg2 @@ -0,0 +1,19 @@ +pkgname='libretools-testpkg2' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) +depends=(sh libretools-testpkg1) + +build() { + cd "$srcdir" + echo '#!/bin/sh' > testpkg2.sh + echo 'libretools-testpkg1' >> testpkg2.sh +} + +package() { + cd "$srcdir" + install -Dm755 testpkg2.sh "$pkgdir"/usr/bin/libretools-testpkg2 +} diff --git a/test/fixtures/libremakepkg/hello.sh b/test/fixtures/libremakepkg/hello.sh new file mode 100644 index 0000000..79a32fd --- /dev/null +++ b/test/fixtures/libremakepkg/hello.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Hello, world!" diff --git a/test/fixtures/librestage/PKGBUILD-hello b/test/fixtures/librestage/PKGBUILD-hello new file mode 100644 index 0000000..5f320fe --- /dev/null +++ b/test/fixtures/librestage/PKGBUILD-hello @@ -0,0 +1,19 @@ +pkgname='libretools-hello' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) +depends=(sh) + +build() { + cd "$srcdir" + echo '#!/bin/sh' > hello.sh + echo 'echo Hello, world!' >> hello.sh +} + +package() { + cd "$srcdir" + install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello +} diff --git a/test/fixtures/librexgettext/.gitignore b/test/fixtures/librexgettext/.gitignore new file mode 100644 index 0000000..f0febc8 --- /dev/null +++ b/test/fixtures/librexgettext/.gitignore @@ -0,0 +1 @@ +!/*.pot diff --git a/test/fixtures/librexgettext/combine.pot b/test/fixtures/librexgettext/combine.pot new file mode 100644 index 0000000..80d066f --- /dev/null +++ b/test/fixtures/librexgettext/combine.pot @@ -0,0 +1,15 @@ +#: librexgettext.d/combine1.sh:4 +msgid "Flag a" +msgstr "" + +#: librexgettext.d/combine1.sh:5 +msgid "Flag b" +msgstr "" + +#: librexgettext.d/combine2.sh:4 +msgid "Flag 1" +msgstr "" + +#: librexgettext.d/combine2.sh:5 +msgid "Flag 2" +msgstr "" diff --git a/test/fixtures/librexgettext/combine1.sh b/test/fixtures/librexgettext/combine1.sh new file mode 100644 index 0000000..9946076 --- /dev/null +++ b/test/fixtures/librexgettext/combine1.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +. libremessages + +flag -a 'Flag a' \ + -b 'Flag b' diff --git a/test/fixtures/librexgettext/combine2.sh b/test/fixtures/librexgettext/combine2.sh new file mode 100644 index 0000000..441e87a --- /dev/null +++ b/test/fixtures/librexgettext/combine2.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +. libremessages + +flag -1 'Flag 1' \ + -2 'Flag 2' diff --git a/test/fixtures/librexgettext/test_librexgettext_fails_on_missing_final_flag_description.sh b/test/fixtures/librexgettext/test_librexgettext_fails_on_missing_final_flag_description.sh new file mode 100644 index 0000000..1c9fc23 --- /dev/null +++ b/test/fixtures/librexgettext/test_librexgettext_fails_on_missing_final_flag_description.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +. libremessages + +flag -a diff --git a/test/fixtures/librexgettext/test_librexgettext_fails_on_subshell_flag_descriptions.sh b/test/fixtures/librexgettext/test_librexgettext_fails_on_subshell_flag_descriptions.sh new file mode 100644 index 0000000..f6be764 --- /dev/null +++ b/test/fixtures/librexgettext/test_librexgettext_fails_on_subshell_flag_descriptions.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +. libremessages + +flag '-a' \ + "$(echo foo)" \ + '-h' \ + help diff --git a/test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.pot b/test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.pot new file mode 100644 index 0000000..0d76a49 --- /dev/null +++ b/test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.pot @@ -0,0 +1,40 @@ +#: librexgettext.d/it_handles_librefetch_flags.sh:4 +msgid "Settings:" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:5 +msgid "Force create mode (don't download)" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:6 +msgid "Force download mode (don't create)" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:7 +msgid "FILE" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:7 +msgid "Use an alternate build script (instead of 'PKGBUILD'). If an " + "SRCBUILD exists in the same directory, it is used instead" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:10 +msgid "Alternate modes:" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:11 +msgid "Generate integrity checks for source files" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:12 +msgid "Print the effective build script (SRCBUILD)" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:13 +msgid "Generate and print the location of the effective makepkg script" +msgstr "" + +#: librexgettext.d/it_handles_librefetch_flags.sh:15 +msgid "Show this message" +msgstr "" diff --git a/test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.sh b/test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.sh new file mode 100644 index 0000000..579ca96 --- /dev/null +++ b/test/fixtures/librexgettext/test_librexgettext_handles_librefetch_flags.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +. libremessages + +flag 'Settings:' \ + "-C" "Force create mode (don't download)" \ + "-D" "Force download mode (don't create)" \ + "-p <$(_ FILE)>" "Use an alternate build script (instead of + 'PKGBUILD'). If an SRCBUILD exists in the same + directory, it is used instead" \ + 'Alternate modes:' \ + "-g, --geninteg" "Generate integrity checks for source files" \ + "-S, --srcbuild" "Print the effective build script (SRCBUILD)" \ + "-M, --makepkg" "Generate and print the location of the + effective makepkg script" \ + "-h, --help" "Show this message" diff --git a/test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.pot b/test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.pot new file mode 100644 index 0000000..cae2a17 --- /dev/null +++ b/test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.pot @@ -0,0 +1,58 @@ +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:4 +msgid "Flag 1" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:4 +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:6 +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:7 +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:8 +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:9 +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:10 +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:11 +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:13 +msgid "OPTARG" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:5 +msgid "Flag 2" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:6 +msgid "Flag 3" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:7 +msgid "Flag 4" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:8 +msgid "Flag 5" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:9 +msgid "Flag 6" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:10 +msgid "Flag 7" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:11 +msgid "Flag 8" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:13 +msgid "FLAG 1" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:14 +msgid "FLAG 2" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:16 +msgid "FLAG A" +msgstr "" + +#: librexgettext.d/it_handles_multiple_skipped_flags.sh:17 +msgid "FLAG B" +msgstr "" diff --git a/test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.sh b/test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.sh new file mode 100644 index 0000000..3b4dcee --- /dev/null +++ b/test/fixtures/librexgettext/test_librexgettext_handles_multiple_skipped_flags.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +. libremessages + +flag "-a $(_ OPTARG)" 'Flag 1' \ + '-b' 'Flag 2' \ + "-c $(_ OPTARG)" 'Flag 3' \ + "-d $(_ OPTARG)" 'Flag 4' \ + "-e $(_ OPTARG)" 'Flag 5' \ + "-f $(_ OPTARG)" 'Flag 6' \ + "-g $(_ OPTARG)" 'Flag 7' \ + "-h $(_ OPTARG)" 'Flag 8' + +flag "-A $(_ OPTARG)" 'FLAG 1' \ + '-B' 'FLAG 2' + +flag '-1' 'FLAG A' \ + '-2' 'FLAG B' diff --git a/test/fixtures/librexgettext/test_librexgettext_handles_zero_flags.pot b/test/fixtures/librexgettext/test_librexgettext_handles_zero_flags.pot new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/librexgettext/test_librexgettext_handles_zero_flags.sh b/test/fixtures/librexgettext/test_librexgettext_handles_zero_flags.sh new file mode 100644 index 0000000..2b6369c --- /dev/null +++ b/test/fixtures/librexgettext/test_librexgettext_handles_zero_flags.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +. libremessages + +flag diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.free b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.free new file mode 100644 index 0000000..4b8f0dd --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.free @@ -0,0 +1,18 @@ +pkgname=wmii +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('MIT') +url="http://wmii.suckless.org/" +depends=('libxft' 'libxrandr' 'libxinerama' 'dash') +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree new file mode 100644 index 0000000..3a7afa4 --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree @@ -0,0 +1,18 @@ +pkgname=wmii +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('MIT') +url="http://wmii.suckless.org/" +depends=('skype') # random non-free package with no other information +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree-replacement b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree-replacement new file mode 100644 index 0000000..7855bdc --- /dev/null +++ b/test/fixtures/pkgbuild-check-nonfree/PKGBUILD.nonfree-replacement @@ -0,0 +1,18 @@ +pkgname=wmii +pkgver=3.9.2 +pkgrel=3 +pkgdesc="A small, dynamic window manager for X11" +arch=('i686' 'x86_64') +license=('MIT') +url="http://wmii.suckless.org/" +depends=('linux') # random non-free package with a replacement +source=() +md5sums=() + +build() { + : +} + +package() { + : +} diff --git a/test/fixtures/toru/libre/simple/PKGBUILD b/test/fixtures/toru/libre/simple/PKGBUILD new file mode 100644 index 0000000..e2d44d1 --- /dev/null +++ b/test/fixtures/toru/libre/simple/PKGBUILD @@ -0,0 +1,11 @@ +pkgname='simple' +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) + +package() { + : +} diff --git a/test/fixtures/toru/libre/split-base/PKGBUILD b/test/fixtures/toru/libre/split-base/PKGBUILD new file mode 100644 index 0000000..ce547c5 --- /dev/null +++ b/test/fixtures/toru/libre/split-base/PKGBUILD @@ -0,0 +1,20 @@ +pkgbase=split-base +pkgname=(FOO BAR BAZ) +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) + +package_FOO() { + : +} + +package_BAR() { + : +} + +package_BAZ() { + : +} diff --git a/test/fixtures/toru/libre/split/PKGBUILD b/test/fixtures/toru/libre/split/PKGBUILD new file mode 100644 index 0000000..fe25a94 --- /dev/null +++ b/test/fixtures/toru/libre/split/PKGBUILD @@ -0,0 +1,19 @@ +pkgname=(foo bar baz) +pkgver=1.0 +license=('GPL') +url='https://parabola.nu' + +pkgrel=1 +arch=(any) + +package_foo() { + : +} + +package_bar() { + : +} + +package_baz() { + : +} diff --git a/test/gitget-test.sh b/test/gitget-test.sh deleted file mode 100644 index 1630fdb..0000000 --- a/test/gitget-test.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env roundup - -describe gitget -. ./test-common.sh - -it_displays_help() { - LC_ALL=C gitget -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_fails_with_0_args() { - gitget >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_forces_url_for_bare() { - mkdir "$tmpdir/src" - cd "$tmpdir/src" - git init . - git config --local user.email 'libretools-test@localhost' - git config --local user.name 'Test Suite' - echo a > a - git add . - git commit -m 'initial commit' - cd .. - gitget bare src dst.git - cd dst.git - [[ "$(git config --get remote.origin.url)" == "$tmpdir/src" ]] - cd .. - gitget bare "file://$PWD/src" dst.git || status=$? - [[ $status != 0 ]] - gitget -f bare "file://$PWD/src" dst.git - cd dst.git - [[ "$(git config --get remote.origin.url)" == "file://$tmpdir/src" ]] -} diff --git a/test/is_built-test.sh b/test/is_built-test.sh deleted file mode 100644 index 66f92bf..0000000 --- a/test/is_built-test.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env roundup - -describe is_built -. ./test-common.sh - -it_displays_help() { - LC_ALL=C is_built -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_fails_with_0_args() { - is_built >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status -gt 1 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_succeeds_with_1_arg() { - is_built sh >$tmpdir/stdout 2>$tmpdir/stderr - - empty $tmpdir/stdout - empty $tmpdir/stderr -} - -it_returns_1_for_non_existent_package() { - is_built phony-ne-package 100 >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status == 1 ]] - empty $tmpdir/stdout - empty $tmpdir/stderr -} - -it_returns_1_for_future_packages() { - # If emacs ever goes rapid release, we might need to change this :P - is_built emacs 100 >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status == 1 ]] - empty $tmpdir/stdout - empty $tmpdir/stderr -} - -it_returns_0_for_past_packages() { - # If emacs ever goes rapid release, we might need to change this :P - is_built emacs 1 >$tmpdir/stdout 2>$tmpdir/stderr - - empty $tmpdir/stdout - empty $tmpdir/stderr -} diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh deleted file mode 100644 index 32d700d..0000000 --- a/test/lib-blacklist-test.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env roundup - -describe libreblacklist -. ./test-common.sh - -it_works_with_just_pkgname() { - v="$(libreblacklist normalize <<> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot - BLACKLIST='phony://example.com' - eot - - libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_fails_cat_with_no_blacklist_or_network() { - cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot - BLACKLIST='phony://example.com' - eot - - libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_fails_update_when_BLACKLIST_is_unset() { - cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot - BLACKLIST= - eot - - libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_fails_cat_when_syntax_error_in_conf() { - # there is a stray single quote in there - 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=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_downloads_the_blacklist_as_needed() { - require network || return 0 - - libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr - - not empty $tmpdir/stdout -} - -it_downloads_the_blacklist_repeatedly() { - require network || return 0 - - libreblacklist update - libreblacklist update -} - -it_displays_help_and_fails_with_no_args() { - LC_ALL=C libreblacklist >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - [[ "$(sed 1q $tmpdir/stderr)" =~ 'Usage: libreblacklist ' ]] -} - -it_displays_help_when_given_h() { - LC_ALL=C libreblacklist -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ 'Usage: libreblacklist ' ]] - empty $tmpdir/stderr -} - -it_displays_help_when_given_h_cat() { - LC_ALL=C libreblacklist -h cat >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" == 'Usage: libreblacklist cat' ]] - empty $tmpdir/stderr -} diff --git a/test/lib-conf-test.sh b/test/lib-conf-test.sh deleted file mode 100644 index cf0b805..0000000 --- a/test/lib-conf-test.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env roundup - -describe lib/conf.sh -. ./test-common.sh - -it_sets_makepkg_vars_in_custom_file() { - unset PKGDEST - touch "$tmpdir/makepkg.conf" - bash -c "$(printf '. $(librelib conf.sh); MAKEPKG_CONF=%q set_var makepkg PKGDEST /pkgdest' "$tmpdir/makepkg.conf")" - . "$tmpdir/makepkg.conf" - [[ $PKGDEST == /pkgdest ]] -} - -it_figures_out_HOME_when_root() { - require sudo || return 0 - # This one is tricky, because it does the job too well, it will find - # the actual HOME, instead of the test environment HOME. Therefore, we - # will just check that [[ $HOME != /root ]] - cd "$tmpdir" - echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh - LIBREHOME=$(testsudo bash ./test.sh) - [[ $LIBREHOME != /root ]] -} - -it_nests_LIBREUSER() { - require sudo || return 0 - [[ $USER != root ]] - cd "$tmpdir" - echo '. $(librelib conf.sh); echo "$LIBREUSER"' > test.sh - - LIBREUSER=$(testsudo bash ./test.sh) - [[ $LIBREUSER == "$USER" ]] - - LIBREUSER=$(testsudo testsudo -u "$USER" bash ./test.sh) - [[ $LIBREUSER == "$USER" ]] -} - -it_respects_custom_HOME() { - cd "$tmpdir" - echo '. $(librelib conf.sh); echo "$LIBREHOME"' > test.sh - - export HOME=/foo - LIBREHOME=$(bash ./test.sh) - - [[ $LIBREHOME == /foo ]] -} diff --git a/test/lib-messages-test.sh b/test/lib-messages-test.sh deleted file mode 100644 index d0b4497..0000000 --- a/test/lib-messages-test.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env roundup - -describe libremessages -. ./test-common.sh - -it_can_be_included_twice() ( - . libremessages - . libremessages -) - -it_can_be_included_with_set_euE() ( - set -euE - . libremessages -) - -it_works_with_no_color_and_set_euE() { - ( - unset TERM - set -euE - . libremessages - msg Foo - ) >$tmpdir/stdout 2>$tmpdir/stderr - - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_can_be_called_without_including() { - libremessages msg Foo >$tmpdir/stdout 2>$tmpdir/stderr - - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_fails_with_msg_and_no_args() { - libremessages msg || status=$? - [[ $status != 0 ]] -} - -it_allows_subheadings_to_flag() { - # Note that old versions of `flag` panicked if given an odd - # number of headings, so give an odd number here. - libremessages flag \ - -a adesc \ - -b bdesc \ - Head1: \ - -c cdesc > $tmpdir/out - cat > $tmpdir/exp <<-eot - -a adesc - -b bdesc - Head1: - -c cdesc - eot - diff -u $tmpdir/exp $tmpdir/out -} - -it_is_quiet_on_stdout_on_errs() { - LC_ALL=C bash -euE -c '. libremessages; setup_traps; false' >"$tmpdir/stdout" 2>"$tmpdir/stderr" || status=$? - - [[ $status != 0 ]] - empty "$tmpdir/stdout" - grep '==> ERROR:' "$tmpdir/stderr" -} diff --git a/test/lib/common.bash b/test/lib/common.bash new file mode 100644 index 0000000..b7e9c10 --- /dev/null +++ b/test/lib/common.bash @@ -0,0 +1,128 @@ +#!/hint/bash + +if [[ -z $LIBRETOOLS_LIBDIR || -z $_librelib_conf_sh_sysconfdir || -z $_librelib_conf_sh_pkgconfdir ]]; then + libremessages error 'Must be run with ./testenv' + exit 1 +fi + +# per-test setup/teardown ############################################ + +common_before() { + tmpdir="$(mktemp -d --tmpdir "test-${roundup_desc//\//-}.${roundup_test_name}.XXXXXXXXXXXX")" + chmod 755 "$tmpdir" + + status=0 + + # Clear the list of makepkg variables + unset PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH + + # Set up a test HOME + export HOME="$tmpdir/home" + export GNUPGHOME="$HOME/.gnupg" + export XDG_CACHE_HOME="$HOME/.cache" + export XDG_CONFIG_HOME="$HOME/.config" + + # Create a GPGKEY + mkdir -p -- "$GNUPGHOME" + chmod 700 -- "$GNUPGHOME" + gpg --quiet --no-tty --batch --gen-key <<-eot + Key-Type: default + Key-Usage: sign + Name-Real: Bob Tester + Name-Email: tester@localhost + Expire-Date: 0 + %no-protection + %commit + eot + export GPGKEY="$(gpg --quiet --list-secret-keys --with-colons | awk -F: '/^sec:/{print substr($5,9)}')" + + # Configure libretools + 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 + REPODEST=ssh://$LIBREUSER@localhost:1863/~/staging/$LIBREUSER/staging/ + eot + install -Dm644 /dev/stdin "$XDG_CONFIG_HOME"/libretools/chroot.conf <<-eot + CHROOTDIR=${chrootdir@Q} + 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 ' + eot + mkdir -p -- "$tmpdir"/workdir/{pkg,src,srcpkg,log}dest +} + +common_after() { + gpg-connect-agent KILLAGENT /bye || true + if [[ -f "$tmpdir/.used-sudo" ]]; then + sudo rm -rf -- "$tmpdir" + else + rm -rf -- "$tmpdir" + fi +} + +before() { + common_before +} + +after() { + common_after +} + +# Utility functions for use in test definitions ###################### + +require() ( + set +x + local missing=() + if libremessages in_array "network" "$@" && ! [[ $NETWORK ]]; then + missing+=('networking') + fi + if libremessages in_array "sudo" "$@" && ! [[ $SUDO ]]; then + missing+=('sudo') + fi + if libremessages in_array "btrfs" "$@" && ! [[ "$(stat -f -c %T "$chrootdir" 2>/dev/null || true)" == 'btrfs' ]]; then + 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 + touch "$tmpdir/.used-sudo" + fi + return 0 +) + +empty() { + diff -u /dev/null "$1" +} + +# Just using '!' doesn't trip `set -e` +not() ( + set +x + # we don't care about what is in the file on 'not empty' + # checks, so redefine 'empty' to be a bit quieter. + empty() { + [[ $(stat -c %s "$1") -eq 0 ]] + } + ! eval "$@" +) + +# Plain command substitution would remove trailing whitespace, despite +# being significant when testing for newline-terminated lines. +equals() { + local stdin + IFS= read -rd '' stdin || : + [[ $1 == "$stdin" ]] +} + +globfile() { + [[ -f $1 ]] +} diff --git a/test/librechroot-test.sh b/test/librechroot-test.sh deleted file mode 100644 index e476f6f..0000000 --- a/test/librechroot-test.sh +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env roundup - -describe librechroot -. ./test-common.sh - -it_creates_repo_for_new_chroots() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db -} - -it_cleans_the_local_repo_correctly() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$roundup_test_name" make - testsudo librechroot -l "$roundup_test_name" clean-repo - testsudo librechroot -l "$roundup_test_name" run test -r /repo/repo.db - # TODO: inspect /repo/* more -} - -it_respects_exit_status_if_out_isnt_a_tty() ( - require network sudo || return 0 - set -o pipefail - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - { testsudo librechroot -l "$roundup_test_name" run bash -c 'exit 3' | cat; } || status=$? - - [[ $status == 3 ]] -) - -it_creates_ca_certificates() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$roundup_test_name" run test -r /etc/ssl/certs/ca-certificates.crt -} - -it_disables_networking_when_requested() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - - testsudo librechroot -l "$roundup_test_name" run curl https://repo.parabola.nu/ >/dev/null - not testsudo librechroot -l "$roundup_test_name" -N run curl https://repo.parabola.nu/ >/dev/null -} - -it_handles_CHROOTEXTRAPKG_correctly() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - - not testsudo librechroot -l "$roundup_test_name" run lsof - echo "CHROOTEXTRAPKG=(lsof)" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf - testsudo librechroot -l "$roundup_test_name" install-name lsof - testsudo librechroot -l "$roundup_test_name" clean-pkgs - testsudo librechroot -l "$roundup_test_name" run lsof - echo "CHROOTEXTRAPKG=()" >> "$XDG_CONFIG_HOME"/libretools/chroot.conf - testsudo librechroot -l "$roundup_test_name" clean-pkgs - not testsudo librechroot -l "$roundup_test_name" run lsof -} - -it_obeys_depends_in_PKGBUILD() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - - # Make sure it's not in the base install - not testsudo librechroot -l "$roundup_test_name" run lsof - # Make sure it removes it without the PKGBUILD - testsudo librechroot -l "$roundup_test_name" install-name lsof - testsudo librechroot -l "$roundup_test_name" run lsof - testsudo librechroot -l "$roundup_test_name" clean-pkgs - not testsudo librechroot -l "$roundup_test_name" run lsof - # Make sure it leaves it with the PKGBUILD - testsudo librechroot -l "$roundup_test_name" install-name lsof - testsudo librechroot -l "$roundup_test_name" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat librechroot.d/PKGBUILD-arches)" - # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. - # https://bugs.archlinux.org/task/56828 - testsudo librechroot -l "$roundup_test_name" run chown -R 99:99 /startdir - testsudo librechroot -l "$roundup_test_name" clean-pkgs - testsudo librechroot -l "$roundup_test_name" run lsof -} - -it_can_install_libretools_with_chcleanup() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - - not testsudo librechroot -l "$roundup_test_name" run test -f /usr/bin/chcleanup - testsudo librechroot -l "$roundup_test_name" run mkdir /startdir - testsudo librechroot -l "$roundup_test_name" run sh -c 'printf "%s\n" "$1" > /startdir/PKGBUILD' -- "$(cat librechroot.d/PKGBUILD-libretools)" - # uid=99 is 'nobody', but we say '99' because sometimes 'nobody' is uid=65534. - # https://bugs.archlinux.org/task/56828 - testsudo librechroot -l "$roundup_test_name" run chown -R 99:99 /startdir - testsudo librechroot -l "$roundup_test_name" clean-pkgs - testsudo librechroot -l "$roundup_test_name" run test -f /usr/bin/chcleanup -} - -it_displays_help_as_normal_user() { - rm -rf "$XDG_CONFIG_HOME" - LC_ALL=C librechroot help >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_otherwise_fails_as_normal_user() { - librechroot -l "$roundup_test_name" run true >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_displays_help_and_fails_with_0_args() { - LC_ALL=C librechroot -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - [[ "$(sed -n 2p $tmpdir/stderr)" =~ Usage:.* ]] -} - -it_obeys_the_n_flag() { - require network sudo || return 0 - - not test -f "$chrootdir/$roundup_test_name/$roundup_test_name/$roundup_test_name.stamp" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -n "$roundup_test_name" -l "$roundup_test_name" run touch /"$roundup_test_name.stamp" - - test -f "$chrootdir/$roundup_test_name/$roundup_test_name/$roundup_test_name.stamp" -} - -# requires sudo so we know it's not failing because it needs root -it_fails_for_unknown_commands() { - require sudo || return 0 - testsudo librechroot phony >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -# requires sudo so we know it's not failing because it needs root -it_fails_for_unknown_flags() { - require sudo || return 0 - testsudo librechroot -q >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_fails_when_syncing_a_copy_with_itself() { - require sudo || return 0 - testsudo timeout 5 librechroot -l root sync || status=$? - case $status in - 0|124|137) # success|timeout+TERM|timeout+KILL - false;; - *) - true;; - esac -} - -it_deletes_copies() { - require network sudo || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$roundup_test_name" make - test -d "$chrootdir/default/$roundup_test_name" - testsudo librechroot -l "$roundup_test_name" delete - not test -e "$chrootdir/default/$roundup_test_name" -} - -it_deletes_subvolumes_recursively() { - require network sudo btrfs || return 0 - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$roundup_test_name" make - testsudo librechroot -l "$roundup_test_name" install-name btrfs-progs - test -d "$chrootdir/default/$roundup_test_name" - not test -e "$chrootdir/default/$roundup_test_name/var/subvolume" - testsudo librechroot -l "$roundup_test_name" run btrfs subvolume create /var/subvolume - test -d "$chrootdir/default/$roundup_test_name/var/subvolume" - testsudo librechroot -l "$roundup_test_name" delete - not test -e "$chrootdir/default/$roundup_test_name" -} - -it_cleans_up_TMPDIR() { - require network sudo || return 0 - - local dir="$tmpdir/tmp" - mkdir -- "$dir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - TMPDIR=$dir testsudo librechroot -l "$roundup_test_name" -A x86_64 make - - # Make sure $dir is now empty - rmdir -- "$dir" -} diff --git a/test/librechroot.d/PKGBUILD-arches b/test/librechroot.d/PKGBUILD-arches deleted file mode 100644 index 6116ad9..0000000 --- a/test/librechroot.d/PKGBUILD-arches +++ /dev/null @@ -1,22 +0,0 @@ -pkgname='libretools-hello' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(i686 x86_64) -depends=(sh) -depends_i686=('lsof') -depends_x86_64=('lsof') - -build() { - cd "$srcdir" - echo '#!/bin/sh' > hello.sh - echo 'echo Hello, world!' >> hello.sh - echo 'lsof' >> hello.sh -} - -package() { - cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello -} diff --git a/test/librechroot.d/PKGBUILD-libretools b/test/librechroot.d/PKGBUILD-libretools deleted file mode 100644 index dcc0f61..0000000 --- a/test/librechroot.d/PKGBUILD-libretools +++ /dev/null @@ -1,20 +0,0 @@ -pkgname='libretools-hello' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) -depends=(libretools) - -build() { - cd "$srcdir" - echo '#!/bin/sh' > hello.sh - echo 'echo Hello, world!' >> hello.sh - echo 'lsof' >> hello.sh -} - -package() { - cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello -} diff --git a/test/libredbdiff-test.sh b/test/libredbdiff-test.sh deleted file mode 100644 index 6cebbf6..0000000 --- a/test/libredbdiff-test.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env roundup - -describe libredbdiff -. ./test-common.sh - -before() { - common_before - - install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libredbdiff.conf" <<-'eot' - statedir="$PWD" - mirror_prbl='https://repo.parabola.nu/$repo/os/$arch' - mirror_arch='https://mirrors.kernel.org/archlinux/$repo/os/$arch' - repos=(libre) - eot -} - -it_displays_help() { - LC_ALL=C libredbdiff -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_handles_packages_with_multiple_provides_explicit() { - cd libredbdiff.d/statedir - - libredbdiff -n libre >$tmpdir/stdout 2>$tmpdir/stderr - - empty $tmpdir/stderr - diff -w ../expected-explicit.txt $tmpdir/stdout -} - -it_handles_packages_with_multiple_provides_implicit() { - cd libredbdiff.d/statedir - - libredbdiff -n >$tmpdir/stdout 2>$tmpdir/stderr - - empty $tmpdir/stderr - diff -w ../expected-implicit.txt $tmpdir/stdout -} - -it_fails_on_bad_repo_args() { - cd libredbdiff.d/statedir - - libredbdiff -n bogus >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} diff --git a/test/libredbdiff.d/expected-explicit.txt b/test/libredbdiff.d/expected-explicit.txt deleted file mode 100644 index 8fb89bf..0000000 --- a/test/libredbdiff.d/expected-explicit.txt +++ /dev/null @@ -1 +0,0 @@ -p linux-libre linux 4.10.12_gnu-2 | 4.10.13-1 diff --git a/test/libredbdiff.d/expected-implicit.txt b/test/libredbdiff.d/expected-implicit.txt deleted file mode 100644 index afc2689..0000000 --- a/test/libredbdiff.d/expected-implicit.txt +++ /dev/null @@ -1,2 +0,0 @@ -[libre] -p linux-libre linux 4.10.12_gnu-2 | 4.10.13-1 diff --git a/test/libredbdiff.d/statedir/pacman.archlinux/local/ALPM_DB_VERSION b/test/libredbdiff.d/statedir/pacman.archlinux/local/ALPM_DB_VERSION deleted file mode 100644 index ec63514..0000000 --- a/test/libredbdiff.d/statedir/pacman.archlinux/local/ALPM_DB_VERSION +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/test/libredbdiff.d/statedir/pacman.archlinux/sync/core.db b/test/libredbdiff.d/statedir/pacman.archlinux/sync/core.db deleted file mode 100644 index b0f737b..0000000 Binary files a/test/libredbdiff.d/statedir/pacman.archlinux/sync/core.db and /dev/null differ diff --git a/test/libredbdiff.d/statedir/pacman.conf.archlinux b/test/libredbdiff.d/statedir/pacman.conf.archlinux deleted file mode 100644 index d4a9c8d..0000000 --- a/test/libredbdiff.d/statedir/pacman.conf.archlinux +++ /dev/null @@ -1,6 +0,0 @@ -[options] -DBPath = ./pacman.archlinux -Architecture = x86_64 - -[core] -Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch diff --git a/test/libredbdiff.d/statedir/pacman.conf.parabola b/test/libredbdiff.d/statedir/pacman.conf.parabola deleted file mode 100644 index 7b553dd..0000000 --- a/test/libredbdiff.d/statedir/pacman.conf.parabola +++ /dev/null @@ -1,6 +0,0 @@ -[options] -DBPath = ./pacman.parabola -Architecture = x86_64 - -[libre] -Server = https://repomirror.parabola.nu/$repo/os/$arch diff --git a/test/libredbdiff.d/statedir/pacman.parabola/local/ALPM_DB_VERSION b/test/libredbdiff.d/statedir/pacman.parabola/local/ALPM_DB_VERSION deleted file mode 100644 index ec63514..0000000 --- a/test/libredbdiff.d/statedir/pacman.parabola/local/ALPM_DB_VERSION +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/test/libredbdiff.d/statedir/pacman.parabola/sync/libre.db b/test/libredbdiff.d/statedir/pacman.parabola/sync/libre.db deleted file mode 100644 index 1bd5065..0000000 Binary files a/test/libredbdiff.d/statedir/pacman.parabola/sync/libre.db and /dev/null differ diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh deleted file mode 100644 index 9edc227..0000000 --- a/test/librefetch-test.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env roundup - -describe librefetch -. ./test-common.sh - -before() { - common_before - - 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="" - source ${_librelib_conf_sh_sysconfdir@Q}/makepkg.d/librefetch.conf - eot - export MAKEPKG_CONF="$XDG_CONFIG_HOME/pacman/makepkg.conf" - - install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/librefetch.conf" <<-eot - MIRRORS=("phony://example.com/dir/") - DOWNLOADER=/usr/bin/false - eot -} - -it_displays_help() { - LC_ALL=C librefetch -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_fails_with_bad_flags() { - local srcball=testpkg-1.0.tar.gz - cp librefetch.d/* "$tmpdir/" - cd "$tmpdir" - mv PKGBUILD{-mksource,} - - librefetch --bogus-flag libre://"$srcball" >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr - not test -e $tmpdir/workdir/srcdest/$srcball -} - -# This test used to be called "it_cleans_src_libre_first", but let's -# be honest: it checks pretty much everything related to normal -# operation. -it_runs_with_mksource() { - local srcball=testpkg-1.0.tar.gz - cp librefetch.d/* "$tmpdir/" - cd "$tmpdir" - mv PKGBUILD{-mksource,} - - # Create garbage, to verifiy that it cleans src-libre first - mkdir -p src-libre/foo - touch src-libre/foo/file - - # Run librefetch - makepkg -g >& log.txt - - # Verify that no temporary files were left around - not test -e librefetch.* - - # Verify that there were no warnings about missing backup=() - # files - not grep -F etc/testpkg.conf log.txt - - # Verify: - # - The srcball was created... - # - ... and is in the correct directory - # - The srcball does not contain the garbage created earlier - # - The files in the srcball are in the correct order (if the - # order isn't ensured, then this would only sometimes fail, - # unfortunately). - bsdtar tf "$tmpdir/workdir/srcdest/$srcball" > list-pkg.txt - diff -u list.txt list-pkg.txt - # Verify that the signature was created and matches - gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null -} - -it_runs_with_srcbuild() { - local srcball=testpkg-1.0.tar.gz - cp librefetch.d/* "$tmpdir/" - cd "$tmpdir" - mv PKGBUILD{-srcbuild,} - mv SRCBUILD{-srcbuild,} - - # Create garbage, to verifiy that it cleans src-libre first - mkdir -p src-libre/foo - touch src-libre/foo/file - - # Run librefetch - makepkg -g - - # Verify that no temporary files were left around - not test -e librefetch.* - - # Verify: - # - The srcball was created... - # - ... and is in the correct directory - # - The srcball does not contain the garbage created earlier - # - The files in the srcball are in the correct order (if the - # order isn't ensured, then this would only sometimes fail, - # unfortunately). - bsdtar tf "$tmpdir/workdir/srcdest/$srcball" > list-pkg.txt - diff -u list.txt list-pkg.txt - # Verify that the signature was created and matches - gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null -} - -it_recurses() { - local srcball=testpkg-1.0.tar.gz - cp librefetch.d/* "$tmpdir/" - cd "$tmpdir" - mv PKGBUILD{-recurse,} - - makepkg -g - bsdtar tf "$tmpdir/workdir/srcdest/$srcball" > list-pkg.txt - diff -u list.txt list-pkg.txt - gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null -} - -it_doesnt_recurse_extra() { - local srcball=testpkg-1.0.tar.gz - cp librefetch.d/* "$tmpdir/" - cd "$tmpdir" - mv PKGBUILD{-recurse,} - - :> "$tmpdir/workdir/srcdest/$srcball" - makepkg -g - empty "$tmpdir/workdir/srcdest/$srcball" - gpg --quiet --verify "$tmpdir/workdir/srcdest/$srcball"{.sig,} 2>/dev/null -} diff --git a/test/librefetch.d/PKGBUILD-mksource b/test/librefetch.d/PKGBUILD-mksource deleted file mode 100644 index 74489de..0000000 --- a/test/librefetch.d/PKGBUILD-mksource +++ /dev/null @@ -1,19 +0,0 @@ -pkgname=testpkg -pkgver=1.0 -pkgrel=1 -pkgdesc=foo -arch=(any) -source=("libre://$pkgname-$pkgver.tar.gz"{,.sig}) -backup=(etc/testpkg.conf) - -mksource() { - mkdir "$srcdir/bar" - local file - for file in '~foo' '~a' a A; do - touch "$srcdir/bar/$file" - done -} - -package() { - :; -} diff --git a/test/librefetch.d/PKGBUILD-recurse b/test/librefetch.d/PKGBUILD-recurse deleted file mode 100644 index fad5976..0000000 --- a/test/librefetch.d/PKGBUILD-recurse +++ /dev/null @@ -1,18 +0,0 @@ -pkgname=testpkg -pkgver=1.0 -pkgrel=1 -pkgdesc=foo -arch=(any) -source=("libre://$pkgname-$pkgver.tar.gz.sig") - -mksource() { - mkdir "$srcdir/bar" - local file - for file in '~foo' '~a' a A; do - touch "$srcdir/bar/$file" - done -} - -package() { - :; -} diff --git a/test/librefetch.d/PKGBUILD-srcbuild b/test/librefetch.d/PKGBUILD-srcbuild deleted file mode 100644 index 40c5c79..0000000 --- a/test/librefetch.d/PKGBUILD-srcbuild +++ /dev/null @@ -1,10 +0,0 @@ -pkgname=testpkg -pkgver=1.0 -pkgrel=1 -pkgdesc=foo -arch=(any) -source=("libre://$pkgname-$pkgver.tar.gz"{,.sig}) - -package() { - :; -} diff --git a/test/librefetch.d/SRCBUILD-srcbuild b/test/librefetch.d/SRCBUILD-srcbuild deleted file mode 100644 index 6f172c5..0000000 --- a/test/librefetch.d/SRCBUILD-srcbuild +++ /dev/null @@ -1,21 +0,0 @@ -pkgname=testpkg -pkgver=1.0 -pkgrel=1 -pkgdesc=foo -arch=(any) -source=() - -PKGDEST=$SRCDEST -PKGEXT=$SRCEXT - -build() { - mkdir "$srcdir/bar" - local file - for file in '~foo' '~a' a A; do - touch "$srcdir/bar/$file" - done -} - -package() { - cp -a -t "$pkgdir" "$srcdir"/* -} diff --git a/test/librefetch.d/list.txt b/test/librefetch.d/list.txt deleted file mode 100644 index 9bd32f4..0000000 --- a/test/librefetch.d/list.txt +++ /dev/null @@ -1,5 +0,0 @@ -bar/ -bar/A -bar/a -bar/~a -bar/~foo diff --git a/test/librelib-test.sh b/test/librelib-test.sh deleted file mode 100644 index ebaf7b2..0000000 --- a/test/librelib-test.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env roundup - -describe librelib -. ./test-common.sh - -it_displays_help_and_fails_with_0_args() { - librelib >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - empty $tmpdir/stdout - [[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]] - [[ $status != 0 ]] -} - -it_fails_with_2_args() { - librelib a b >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - empty $tmpdir/stdout - not empty $tmpdir/stderr - [[ $status != 0 ]] -} - -it_displays_usage_text() { - librelib -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -# Nothing in $(libdir) should be executable anymore (except that -# $(libexecdir)=$(libdir), and executable things go in there. But I -# digress, libremessages should not be executable anymore). -it_finds_messages() { - v1=$(librelib messages) - v2=$(librelib libremessages) - v3=$(librelib messages.sh) - v4=$(librelib libremessages.sh) - - [[ -r "$v1" && ! -x "$v1" ]] - [[ "$v1" == "$v2" ]] - [[ "$v1" == "$v3" ]] - [[ "$v1" == "$v4" ]] -} - -# conf.sh is non-executable -it_finds_conf() { - v1=$(librelib conf) - v2=$(librelib libreconf) - v3=$(librelib conf.sh) - v4=$(librelib libreconf.sh) - - [[ -r "$v1" && ! -x "$v1" ]] - [[ "$v1" == "$v2" ]] - [[ "$v1" == "$v3" ]] - [[ "$v1" == "$v4" ]] -} - -it_fails_to_find_phony() { - librelib phony >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - empty $tmpdir/stdout - not empty $tmpdir/stderr - [[ $status != 0 ]] -} diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh deleted file mode 100644 index 36176d3..0000000 --- a/test/libremakepkg-test.sh +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env roundup - -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" - cd "$tmpdir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" - - globfile libretools-hello-1.0-1-any.pkg.tar.?z -} - -it_disables_networking_during_prepare() { - require network sudo || return 0 - cp libremakepkg.d/PKGBUILD-netprepare "$tmpdir/PKGBUILD" - cd "$tmpdir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - not testsudo libremakepkg -l "$roundup_test_name" - not globfile libretools-netprepare-1.0-1-any.pkg.tar.?z - testsudo libremakepkg -l "$roundup_test_name" -N - globfile libretools-netprepare-1.0-1-any.pkg.tar.?z -} - -it_disables_networking_during_build() { - require network sudo || return 0 - cp libremakepkg.d/PKGBUILD-netbuild "$tmpdir/PKGBUILD" - cd "$tmpdir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - not testsudo libremakepkg -l "$roundup_test_name" - not globfile libretools-netbuild-1.0-1-any.pkg.tar.?z - testsudo libremakepkg -l "$roundup_test_name" -N - globfile libretools-netbuild-1.0-1-any.pkg.tar.?z -} - -it_disables_networking_during_package() { - require network sudo || return 0 - cp libremakepkg.d/PKGBUILD-netpackage "$tmpdir/PKGBUILD" - cd "$tmpdir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - not testsudo libremakepkg -l "$roundup_test_name" - not globfile libretools-netpackage-1.0-1-any.pkg.tar.?z - testsudo libremakepkg -l "$roundup_test_name" -N - globfile libretools-netpackage-1.0-1-any.pkg.tar.?z -} - -it_cleans_the_chroot_before_building() { - require network sudo || return 0 - # 1. First, we build testpkg1 - # 2. Then, we build testpkg2, which depends on testpkg1 - # Therefore, testpkg1 will be installed after testpkg2 is built, we - # check for that. - # 3. Then, we build hello, which depends on neither, so testpkg1 should - # be removed. - - # Also, do funny things with the output of libremakepkg to get a helpful - # fail case. - - mkdir -p "$tmpdir"/{1,2,3} - cp libremakepkg.d/PKGBUILD-testpkg1 "$tmpdir/1/PKGBUILD" - cp libremakepkg.d/PKGBUILD-testpkg2 "$tmpdir/2/PKGBUILD" - cp libremakepkg.d/PKGBUILD-hello "$tmpdir/3/PKGBUILD" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - - cd "$tmpdir/1" - testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } - - cd "$tmpdir/2" - testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } - testsudo librechroot -l "$roundup_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() { - not testsudo librechroot -l "$roundup_test_name" run test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar.?z - - cd "$tmpdir/3" - testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } - not testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail' -} - -it_handles_PKGDEST_not_existing() { - require network sudo || return 0 - cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" - cd "$tmpdir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo env PKGDEST="$tmpdir/dest/pkgdest" libremakepkg -l "$roundup_test_name" - - globfile dest/pkgdest/libretools-hello-1.0-1-any.pkg.tar.?z -} - -it_displays_help_as_normal_user() { - rm -rf "$XDG_CONFIG_HOME" - LC_ALL=C libremakepkg -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_otherwise_fails_as_normal_user() { - # I do this to give it a chance of passing - cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" - cd "$tmpdir" - - libremakepkg >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_fails_if_a_hook_fails() { - require network sudo || return 0 - cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" - cd "$tmpdir" - - cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot - BLACKLIST='phony://example.com' - eot - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - tail -n1 $tmpdir/stderr | grep -qF '==> ERROR: Failure(s) in check_pkgbuild: check_pkgbuild_nonfree' -} - -it_detects_distcc_files() { - require network sudo || return 0 - cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" - cd "$tmpdir" - - cat >> "$XDG_CONFIG_HOME/libretools/chroot.conf" <<-eot - CHROOTEXTRAPKG+=(distcc-nozeroconf socat) - eot - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$roundup_test_name" install-name distcc-nozeroconf socat - - # first make sure that the engine works - testsudo libremakepkg -l "$roundup_test_name" - globfile libretools-hello-1.0-1-any.pkg.tar.?z - rm -f -- libretools-hello-1.0-1-any.pkg.tar.?z - # now throw a wrench in it - testsudo librechroot -l "$roundup_test_name" run touch /bin/distcc-tool - # and make sure that the engine broke - testsudo libremakepkg -l "$roundup_test_name" || status=$? - [[ $status != 0 ]] - not globfile libretools-hello-1.0-1-any.pkg.tar.?z -} - -it_allows_distcc_on_long_chrootpaths() { - # The maximum AF_UNIX socket path is 108 bytes; so let's have - # a chroot name that's guaranteed to be >110 characters. - local chrootname=$roundup_test_name.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - - require network sudo || return 0 - cp libremakepkg.d/PKGBUILD-distcc "$tmpdir/PKGBUILD" - cd "$tmpdir" - - cat >> "$XDG_CONFIG_HOME/libretools/chroot.conf" <<-eot - CHROOTEXTRAPKG+=(distcc-nozeroconf socat) - eot - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo librechroot -l "$chrootname" install-name distcc-nozeroconf socat - testsudo libremakepkg -l "$chrootname" - globfile libretools-distcc-1.0-1-any.pkg.tar.?z -} - -it_doesnt_symlink_outputs() { - require network sudo || return 0 - - sed -i /^unset/d "$XDG_CONFIG_HOME/pacman/makepkg.conf" - - cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" - cd "$tmpdir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" - - not stat libretools-hello-1.0-1-any.pkg.tar.?z - not stat libretools-hello-1.0-1-any.src.tar.?z - globfile "$tmpdir/workdir/pkgdest"/libretools-hello-1.0-1-any.pkg.tar.?z - globfile "$tmpdir/workdir/srcpkgdest"/libretools-hello-1.0-1-any.src.tar.?z -} - -it_succeeds_with_good_signatures() { - require network sudo || return 0 - - cp libremakepkg.d/PKGBUILD-signed "$tmpdir/PKGBUILD" - cp libremakepkg.d/hello.sh "$tmpdir/hello.sh" - cd "$tmpdir" - gpg --detach-sign --use-agent --no-armor hello.sh - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" -} - -it_fails_with_bad_signatures() { - require network sudo || return 0 - - cp libremakepkg.d/PKGBUILD-signed "$tmpdir/PKGBUILD" - cp libremakepkg.d/hello.sh "$tmpdir/hello.sh" - cd "$tmpdir" - gpg --detach-sign --use-agent --no-armor hello.sh - echo 'echo pwned' >> hello.sh - makepkg -g >> PKGBUILD - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - not testsudo libremakepkg -l "$roundup_test_name" -} - -it_does_not_run_pkgver() { - require network sudo || return 0 - - cp libremakepkg.d/PKGBUILD-pkgver "$tmpdir/PKGBUILD" - pushd "$tmpdir" - - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" - - globfile libretools-pkgver-1-1-any.pkg.tar.?z - not globfile libretools-pkgver-2-1-any.pkg.tar.?z - popd - diff -u libremakepkg.d/PKGBUILD-pkgver "$tmpdir/PKGBUILD" -} diff --git a/test/libremakepkg.d/PKGBUILD-distcc b/test/libremakepkg.d/PKGBUILD-distcc deleted file mode 100644 index 5127ae6..0000000 --- a/test/libremakepkg.d/PKGBUILD-distcc +++ /dev/null @@ -1,23 +0,0 @@ -pkgname='libretools-distcc' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) -depends=(sh) - -build() { - cd "$srcdir" - echo '#!/bin/sh' > hello.sh - echo 'echo Hello, world!' >> hello.sh - # I don't like hard-coding in an implementation detail, but - # this is the simplest way to verify that `distcc-tool - # odaemon` started correctly. - [[ -S /socket ]] -} - -package() { - cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello -} diff --git a/test/libremakepkg.d/PKGBUILD-hello b/test/libremakepkg.d/PKGBUILD-hello deleted file mode 100644 index 5f320fe..0000000 --- a/test/libremakepkg.d/PKGBUILD-hello +++ /dev/null @@ -1,19 +0,0 @@ -pkgname='libretools-hello' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) -depends=(sh) - -build() { - cd "$srcdir" - echo '#!/bin/sh' > hello.sh - echo 'echo Hello, world!' >> hello.sh -} - -package() { - cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello -} diff --git a/test/libremakepkg.d/PKGBUILD-netbuild b/test/libremakepkg.d/PKGBUILD-netbuild deleted file mode 100644 index 4db1274..0000000 --- a/test/libremakepkg.d/PKGBUILD-netbuild +++ /dev/null @@ -1,17 +0,0 @@ -pkgname='libretools-netbuild' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) - -build() { - cd "$srcdir" - curl https://repo.parabola.nu/ > index.html -} - -package() { - cd "$srcdir" - install -Dm644 index.html "$pkgdir"/usr/share/$pkgname/index.html -} diff --git a/test/libremakepkg.d/PKGBUILD-netpackage b/test/libremakepkg.d/PKGBUILD-netpackage deleted file mode 100644 index 6cadcf8..0000000 --- a/test/libremakepkg.d/PKGBUILD-netpackage +++ /dev/null @@ -1,12 +0,0 @@ -pkgname='libretools-netpackage' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) - -package() { - install -d "$pkgdir"/usr/share/$pkgname - curl https://repo.parabola.nu/ > "$pkgdir"/usr/share/$pkgname/index.html -} diff --git a/test/libremakepkg.d/PKGBUILD-netprepare b/test/libremakepkg.d/PKGBUILD-netprepare deleted file mode 100644 index efb7a43..0000000 --- a/test/libremakepkg.d/PKGBUILD-netprepare +++ /dev/null @@ -1,17 +0,0 @@ -pkgname='libretools-netprepare' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) - -prepare() { - cd "$srcdir" - curl https://repo.parabola.nu/ > index.html -} - -package() { - cd "$srcdir" - install -Dm644 index.html "$pkgdir"/usr/share/$pkgname/index.html -} diff --git a/test/libremakepkg.d/PKGBUILD-pkgver b/test/libremakepkg.d/PKGBUILD-pkgver deleted file mode 100644 index 6b92d84..0000000 --- a/test/libremakepkg.d/PKGBUILD-pkgver +++ /dev/null @@ -1,23 +0,0 @@ -pkgname='libretools-pkgver' -pkgver=1 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) -depends=(sh) - -pkgver() { - echo 2 -} - -build() { - cd "$srcdir" - echo '#!/bin/sh' > hello.sh - echo 'echo Hello, world!' >> hello.sh -} - -package() { - cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello -} diff --git a/test/libremakepkg.d/PKGBUILD-signed b/test/libremakepkg.d/PKGBUILD-signed deleted file mode 100644 index 0979a85..0000000 --- a/test/libremakepkg.d/PKGBUILD-signed +++ /dev/null @@ -1,17 +0,0 @@ -pkgname='libretools-signed' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -source=(hello.sh{,.sig}) -sha256sums=('1e70cef0dfe5ce1120ccde5e1551c7277bcddaa75a1808f49512f404e6b8aec8' - 'SKIP') - -pkgrel=1 -arch=(any) -depends=(sh) - -package() { - cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello -} diff --git a/test/libremakepkg.d/PKGBUILD-testpkg1 b/test/libremakepkg.d/PKGBUILD-testpkg1 deleted file mode 100644 index 8da1f14..0000000 --- a/test/libremakepkg.d/PKGBUILD-testpkg1 +++ /dev/null @@ -1,19 +0,0 @@ -pkgname='libretools-testpkg1' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) -depends=(sh) - -build() { - cd "$srcdir" - echo '#!/bin/sh' > testpkg1.sh - echo 'echo testpkg1' >> testpkg1.sh -} - -package() { - cd "$srcdir" - install -Dm755 testpkg1.sh "$pkgdir"/usr/bin/libretools-testpkg1 -} diff --git a/test/libremakepkg.d/PKGBUILD-testpkg2 b/test/libremakepkg.d/PKGBUILD-testpkg2 deleted file mode 100644 index 65d558e..0000000 --- a/test/libremakepkg.d/PKGBUILD-testpkg2 +++ /dev/null @@ -1,19 +0,0 @@ -pkgname='libretools-testpkg2' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) -depends=(sh libretools-testpkg1) - -build() { - cd "$srcdir" - echo '#!/bin/sh' > testpkg2.sh - echo 'libretools-testpkg1' >> testpkg2.sh -} - -package() { - cd "$srcdir" - install -Dm755 testpkg2.sh "$pkgdir"/usr/bin/libretools-testpkg2 -} diff --git a/test/libremakepkg.d/hello.sh b/test/libremakepkg.d/hello.sh deleted file mode 100644 index 79a32fd..0000000 --- a/test/libremakepkg.d/hello.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -echo "Hello, world!" diff --git a/test/librerelease-test.sh b/test/librerelease-test.sh deleted file mode 100644 index 5ffbb14..0000000 --- a/test/librerelease-test.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env roundup - -describe librerelease -. ./test-common.sh - -it_displays_usage_text() { - rm -rf "$XDG_CONFIG_HOME" - LC_ALL=C librerelease -h >"$tmpdir/stdout" 2>"$tmpdir/stderr" - - [[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]] - empty "$tmpdir/stderr" -} - -it_lists_all_files() { - WORKDIR="$tmpdir/workdir" - mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2/sub" - touch \ - "$WORKDIR/staging/repo1/file1" \ - "$WORKDIR/staging/repo1/file2" \ - "$WORKDIR/staging/repo2/file with spaces" \ - "$WORKDIR/staging/repo2/sub/subfolder" - unset WORKDIR - LC_ALL=C librerelease -l &>"$tmpdir/list" || { status=$?; cat "$tmpdir/list"; return $status; } - - cat > "$tmpdir/list-correct" <<-eot - -> repo1 - file1 - file2 - -> repo2 - file with spaces - sub/subfolder - eot - - diff "$tmpdir/list-correct" "$tmpdir/list" -} - -it_fails_if_gpgkey_not_set() { - unset GPGKEY - - WORKDIR="$tmpdir/workdir" - mkdir -p "$WORKDIR/staging/repo1" "$WORKDIR/staging/repo2/sub" - touch \ - "$WORKDIR/staging/repo1/file1" \ - "$WORKDIR/staging/repo1/file2" \ - "$WORKDIR/staging/repo2/file with spaces" \ - "$WORKDIR/staging/repo2/sub/subfolder" - unset WORKDIR - LC_ALL=C librerelease -l >"$tmpdir/stdout" 2>"$tmpdir/stderr" || status=$? - - [[ $status != 0 ]] - empty "$tmpdir/stdout" - grep GPGKEY "$tmpdir/stderr" -} diff --git a/test/librestage-test.sh b/test/librestage-test.sh deleted file mode 100644 index 2fe3415..0000000 --- a/test/librestage-test.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env roundup - -describe librestage -. ./test-common.sh - -it_displays_usage_text() { - rm -rf "$XDG_CONFIG_HOME" - LC_ALL=C librestage -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q "$tmpdir/stdout")" =~ Usage:.* ]] - empty "$tmpdir/stderr" -} - -it_fails_with_0_args() { - librestage >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty "$tmpdir/stdout" - not empty "$tmpdir/stderr" -} - -it_fails_with_invalid_args() { - librestage -q >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty "$tmpdir/stdout" - not empty "$tmpdir/stderr" -} - -it_guesses_the_repo() { - nochroot=false; require network sudo || nochroot=true - mkdir -p -- "$tmpdir/reponame/libretools-hello" - cp librestage.d/PKGBUILD-hello "$tmpdir/reponame/libretools-hello/PKGBUILD" - cd "$tmpdir/reponame/libretools-hello" - - if $nochroot; then - makepkg - else - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" - fi - librestage - - find "$tmpdir" -not -type d -exec ls -ld -- {} + - globfile $tmpdir/workdir/staging/reponame/libretools-hello-1.0-1-any.pkg.tar.?z - $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z -} - -it_stages_packages_without_PKGDEST() { - nochroot=false; require network sudo || nochroot=true - - cat >> "$XDG_CONFIG_HOME/pacman/makepkg.conf" <<-eot - PKGDEST='' - SRCPKGDEST='' - eot - - cp librestage.d/PKGBUILD-hello "$tmpdir/PKGBUILD" - cd "$tmpdir" - - if $nochroot; then - makepkg - else - libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" - fi - librestage repo1 - - find "$tmpdir" -not -type d -exec ls -ld -- {} + - globfile $tmpdir/workdir/staging/repo1/libretools-hello-1.0-1-any.pkg.tar.?z - $nochroot || globfile $tmpdir/workdir/staging/sources/parabola/libretools-hello-1.0-1-any.src.tar.?z -} diff --git a/test/librestage.d/PKGBUILD-hello b/test/librestage.d/PKGBUILD-hello deleted file mode 100644 index 5f320fe..0000000 --- a/test/librestage.d/PKGBUILD-hello +++ /dev/null @@ -1,19 +0,0 @@ -pkgname='libretools-hello' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) -depends=(sh) - -build() { - cd "$srcdir" - echo '#!/bin/sh' > hello.sh - echo 'echo Hello, world!' >> hello.sh -} - -package() { - cd "$srcdir" - install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello -} diff --git a/test/librexgettext-test.sh b/test/librexgettext-test.sh deleted file mode 100644 index d4c8028..0000000 --- a/test/librexgettext-test.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env roundup - -describe librexgettext -. ./test-common.sh - -it_displays_help() { - LC_ALL=C librexgettext -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_fails_with_0_args() { - librexgettext >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -passcase() { - librexgettext librexgettext.d/$roundup_test_name.sh > $tmpdir/actual.pot 2>$tmpdir/stderr - empty $tmpdir/stderr - diff -u librexgettext.d/$roundup_test_name.pot $tmpdir/actual.pot -} - -it_handles_multiple_skipped_flags() { passcase; } -it_handles_zero_flags() { passcase; } -it_handles_librefetch_flags() { passcase; } - -it_fails_on_missing_final_flag_description() { - librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4:"* ]] -} - - -it_fails_on_subshell_flag_descriptions() { - librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4-6:"* ]] -} - -it_doesnt_keep_failing() { - librexgettext some_file_that_doesnt_exist >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - [[ $status != 0 ]] - empty $tmpdir/stdout - [[ "$(wc -l <$tmpdir/stderr)" == 1 ]] -} - -it_handles_multiple_files() { - librexgettext librexgettext.d/combine1.sh librexgettext.d/combine2.sh > $tmpdir/actual.pot 2>$tmpdir/stderr - empty $tmpdir/stderr - diff -u librexgettext.d/combine.pot $tmpdir/actual.pot -} diff --git a/test/librexgettext.d/.gitignore b/test/librexgettext.d/.gitignore deleted file mode 100644 index f0febc8..0000000 --- a/test/librexgettext.d/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!/*.pot diff --git a/test/librexgettext.d/combine.pot b/test/librexgettext.d/combine.pot deleted file mode 100644 index 80d066f..0000000 --- a/test/librexgettext.d/combine.pot +++ /dev/null @@ -1,15 +0,0 @@ -#: librexgettext.d/combine1.sh:4 -msgid "Flag a" -msgstr "" - -#: librexgettext.d/combine1.sh:5 -msgid "Flag b" -msgstr "" - -#: librexgettext.d/combine2.sh:4 -msgid "Flag 1" -msgstr "" - -#: librexgettext.d/combine2.sh:5 -msgid "Flag 2" -msgstr "" diff --git a/test/librexgettext.d/combine1.sh b/test/librexgettext.d/combine1.sh deleted file mode 100644 index 9946076..0000000 --- a/test/librexgettext.d/combine1.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -. libremessages - -flag -a 'Flag a' \ - -b 'Flag b' diff --git a/test/librexgettext.d/combine2.sh b/test/librexgettext.d/combine2.sh deleted file mode 100644 index 441e87a..0000000 --- a/test/librexgettext.d/combine2.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -. libremessages - -flag -1 'Flag 1' \ - -2 'Flag 2' diff --git a/test/librexgettext.d/it_fails_on_missing_final_flag_description.sh b/test/librexgettext.d/it_fails_on_missing_final_flag_description.sh deleted file mode 100644 index 1c9fc23..0000000 --- a/test/librexgettext.d/it_fails_on_missing_final_flag_description.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -. libremessages - -flag -a diff --git a/test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh b/test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh deleted file mode 100644 index f6be764..0000000 --- a/test/librexgettext.d/it_fails_on_subshell_flag_descriptions.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -. libremessages - -flag '-a' \ - "$(echo foo)" \ - '-h' \ - help diff --git a/test/librexgettext.d/it_handles_librefetch_flags.pot b/test/librexgettext.d/it_handles_librefetch_flags.pot deleted file mode 100644 index 0d76a49..0000000 --- a/test/librexgettext.d/it_handles_librefetch_flags.pot +++ /dev/null @@ -1,40 +0,0 @@ -#: librexgettext.d/it_handles_librefetch_flags.sh:4 -msgid "Settings:" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:5 -msgid "Force create mode (don't download)" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:6 -msgid "Force download mode (don't create)" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:7 -msgid "FILE" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:7 -msgid "Use an alternate build script (instead of 'PKGBUILD'). If an " - "SRCBUILD exists in the same directory, it is used instead" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:10 -msgid "Alternate modes:" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:11 -msgid "Generate integrity checks for source files" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:12 -msgid "Print the effective build script (SRCBUILD)" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:13 -msgid "Generate and print the location of the effective makepkg script" -msgstr "" - -#: librexgettext.d/it_handles_librefetch_flags.sh:15 -msgid "Show this message" -msgstr "" diff --git a/test/librexgettext.d/it_handles_librefetch_flags.sh b/test/librexgettext.d/it_handles_librefetch_flags.sh deleted file mode 100644 index 579ca96..0000000 --- a/test/librexgettext.d/it_handles_librefetch_flags.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -. libremessages - -flag 'Settings:' \ - "-C" "Force create mode (don't download)" \ - "-D" "Force download mode (don't create)" \ - "-p <$(_ FILE)>" "Use an alternate build script (instead of - 'PKGBUILD'). If an SRCBUILD exists in the same - directory, it is used instead" \ - 'Alternate modes:' \ - "-g, --geninteg" "Generate integrity checks for source files" \ - "-S, --srcbuild" "Print the effective build script (SRCBUILD)" \ - "-M, --makepkg" "Generate and print the location of the - effective makepkg script" \ - "-h, --help" "Show this message" diff --git a/test/librexgettext.d/it_handles_multiple_skipped_flags.pot b/test/librexgettext.d/it_handles_multiple_skipped_flags.pot deleted file mode 100644 index cae2a17..0000000 --- a/test/librexgettext.d/it_handles_multiple_skipped_flags.pot +++ /dev/null @@ -1,58 +0,0 @@ -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:4 -msgid "Flag 1" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:4 -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:6 -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:7 -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:8 -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:9 -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:10 -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:11 -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:13 -msgid "OPTARG" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:5 -msgid "Flag 2" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:6 -msgid "Flag 3" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:7 -msgid "Flag 4" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:8 -msgid "Flag 5" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:9 -msgid "Flag 6" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:10 -msgid "Flag 7" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:11 -msgid "Flag 8" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:13 -msgid "FLAG 1" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:14 -msgid "FLAG 2" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:16 -msgid "FLAG A" -msgstr "" - -#: librexgettext.d/it_handles_multiple_skipped_flags.sh:17 -msgid "FLAG B" -msgstr "" diff --git a/test/librexgettext.d/it_handles_multiple_skipped_flags.sh b/test/librexgettext.d/it_handles_multiple_skipped_flags.sh deleted file mode 100644 index 3b4dcee..0000000 --- a/test/librexgettext.d/it_handles_multiple_skipped_flags.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -. libremessages - -flag "-a $(_ OPTARG)" 'Flag 1' \ - '-b' 'Flag 2' \ - "-c $(_ OPTARG)" 'Flag 3' \ - "-d $(_ OPTARG)" 'Flag 4' \ - "-e $(_ OPTARG)" 'Flag 5' \ - "-f $(_ OPTARG)" 'Flag 6' \ - "-g $(_ OPTARG)" 'Flag 7' \ - "-h $(_ OPTARG)" 'Flag 8' - -flag "-A $(_ OPTARG)" 'FLAG 1' \ - '-B' 'FLAG 2' - -flag '-1' 'FLAG A' \ - '-2' 'FLAG B' diff --git a/test/librexgettext.d/it_handles_zero_flags.pot b/test/librexgettext.d/it_handles_zero_flags.pot deleted file mode 100644 index e69de29..0000000 diff --git a/test/librexgettext.d/it_handles_zero_flags.sh b/test/librexgettext.d/it_handles_zero_flags.sh deleted file mode 100644 index 2b6369c..0000000 --- a/test/librexgettext.d/it_handles_zero_flags.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -. libremessages - -flag diff --git a/test/pkgbuild-check-nonfree-test.sh b/test/pkgbuild-check-nonfree-test.sh deleted file mode 100644 index 0582e29..0000000 --- a/test/pkgbuild-check-nonfree-test.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env roundup - -describe pkgbuild-check-nonfree -. ./test-common.sh - -before() { - common_before - - # 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 - eot -} - -it_displays_usage_text() { - # This test seems silly, but it makes sure that it is executable, - # syntactically correct, and loading libraries works. - LC_ALL=C pkgbuild-check-nonfree -h >$tmpdir/stdout 2>$tmpdir/stderr - status=$? - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr - [[ $status == 0 ]] -} - -it_succeeds_for_free_depends() { - pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - empty $tmpdir/stdout - not empty $tmpdir/stderr - [[ $status == 0 ]] -} - -it_succeeds_for_nonfree_depend_with_replacement() { - pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - empty $tmpdir/stdout - not empty $tmpdir/stderr - [[ $status == 0 ]] -} - -it_fails_for_nonfree_depend() { - pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr - - local pcn_stat=$status - - pkgbuild-summarize-nonfree $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - [[ $status != 0 ]] - empty $tmpdir/stdout - not empty $tmpdir/stderr -} - -it_fails_when_there_is_no_blacklist() { - rm $XDG_CACHE_HOME/libretools/blacklist.txt - - pkgbuild-check-nonfree pkgbuild-check-nonfree.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - - empty $tmpdir/stdout - not empty $tmpdir/stderr - [[ $status != 0 ]] && [[ $status != 15 ]] -} diff --git a/test/pkgbuild-check-nonfree.d/PKGBUILD.free b/test/pkgbuild-check-nonfree.d/PKGBUILD.free deleted file mode 100644 index 4b8f0dd..0000000 --- a/test/pkgbuild-check-nonfree.d/PKGBUILD.free +++ /dev/null @@ -1,18 +0,0 @@ -pkgname=wmii -pkgver=3.9.2 -pkgrel=3 -pkgdesc="A small, dynamic window manager for X11" -arch=('i686' 'x86_64') -license=('MIT') -url="http://wmii.suckless.org/" -depends=('libxft' 'libxrandr' 'libxinerama' 'dash') -source=() -md5sums=() - -build() { - : -} - -package() { - : -} diff --git a/test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree b/test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree deleted file mode 100644 index 3a7afa4..0000000 --- a/test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree +++ /dev/null @@ -1,18 +0,0 @@ -pkgname=wmii -pkgver=3.9.2 -pkgrel=3 -pkgdesc="A small, dynamic window manager for X11" -arch=('i686' 'x86_64') -license=('MIT') -url="http://wmii.suckless.org/" -depends=('skype') # random non-free package with no other information -source=() -md5sums=() - -build() { - : -} - -package() { - : -} diff --git a/test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree-replacement b/test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree-replacement deleted file mode 100644 index 7855bdc..0000000 --- a/test/pkgbuild-check-nonfree.d/PKGBUILD.nonfree-replacement +++ /dev/null @@ -1,18 +0,0 @@ -pkgname=wmii -pkgver=3.9.2 -pkgrel=3 -pkgdesc="A small, dynamic window manager for X11" -arch=('i686' 'x86_64') -license=('MIT') -url="http://wmii.suckless.org/" -depends=('linux') # random non-free package with a replacement -source=() -md5sums=() - -build() { - : -} - -package() { - : -} diff --git a/test/test-common.sh b/test/test-common.sh deleted file mode 100644 index b7e9c10..0000000 --- a/test/test-common.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/hint/bash - -if [[ -z $LIBRETOOLS_LIBDIR || -z $_librelib_conf_sh_sysconfdir || -z $_librelib_conf_sh_pkgconfdir ]]; then - libremessages error 'Must be run with ./testenv' - exit 1 -fi - -# per-test setup/teardown ############################################ - -common_before() { - tmpdir="$(mktemp -d --tmpdir "test-${roundup_desc//\//-}.${roundup_test_name}.XXXXXXXXXXXX")" - chmod 755 "$tmpdir" - - status=0 - - # Clear the list of makepkg variables - unset PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH - - # Set up a test HOME - export HOME="$tmpdir/home" - export GNUPGHOME="$HOME/.gnupg" - export XDG_CACHE_HOME="$HOME/.cache" - export XDG_CONFIG_HOME="$HOME/.config" - - # Create a GPGKEY - mkdir -p -- "$GNUPGHOME" - chmod 700 -- "$GNUPGHOME" - gpg --quiet --no-tty --batch --gen-key <<-eot - Key-Type: default - Key-Usage: sign - Name-Real: Bob Tester - Name-Email: tester@localhost - Expire-Date: 0 - %no-protection - %commit - eot - export GPGKEY="$(gpg --quiet --list-secret-keys --with-colons | awk -F: '/^sec:/{print substr($5,9)}')" - - # Configure libretools - 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 - REPODEST=ssh://$LIBREUSER@localhost:1863/~/staging/$LIBREUSER/staging/ - eot - install -Dm644 /dev/stdin "$XDG_CONFIG_HOME"/libretools/chroot.conf <<-eot - CHROOTDIR=${chrootdir@Q} - 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 ' - eot - mkdir -p -- "$tmpdir"/workdir/{pkg,src,srcpkg,log}dest -} - -common_after() { - gpg-connect-agent KILLAGENT /bye || true - if [[ -f "$tmpdir/.used-sudo" ]]; then - sudo rm -rf -- "$tmpdir" - else - rm -rf -- "$tmpdir" - fi -} - -before() { - common_before -} - -after() { - common_after -} - -# Utility functions for use in test definitions ###################### - -require() ( - set +x - local missing=() - if libremessages in_array "network" "$@" && ! [[ $NETWORK ]]; then - missing+=('networking') - fi - if libremessages in_array "sudo" "$@" && ! [[ $SUDO ]]; then - missing+=('sudo') - fi - if libremessages in_array "btrfs" "$@" && ! [[ "$(stat -f -c %T "$chrootdir" 2>/dev/null || true)" == 'btrfs' ]]; then - 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 - touch "$tmpdir/.used-sudo" - fi - return 0 -) - -empty() { - diff -u /dev/null "$1" -} - -# Just using '!' doesn't trip `set -e` -not() ( - set +x - # we don't care about what is in the file on 'not empty' - # checks, so redefine 'empty' to be a bit quieter. - empty() { - [[ $(stat -c %s "$1") -eq 0 ]] - } - ! eval "$@" -) - -# Plain command substitution would remove trailing whitespace, despite -# being significant when testing for newline-terminated lines. -equals() { - local stdin - IFS= read -rd '' stdin || : - [[ $1 == "$stdin" ]] -} - -globfile() { - [[ -f $1 ]] -} diff --git a/test/toru-path-test.sh b/test/toru-path-test.sh deleted file mode 100644 index 5576ad7..0000000 --- a/test/toru-path-test.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env roundup - -describe toru-path -. ./test-common.sh - -it_displays_help() { - LC_ALL=C toru-path -h >$tmpdir/stdout 2>$tmpdir/stderr - - [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] - empty $tmpdir/stderr -} - -it_runs() { - cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot - TORUPATH=${tmpdir@Q} - REPOS=(libre) - eot - cat >> "$HOME/.abs.conf" <<-eot - ABSROOT=${PWD@Q}/toru.d - eot - - toru-path - - tcamgr list "$tmpdir/paths.tch"|LC_COLLATE=C sort|while read -r key; do - val="$(tcamgr get "$tmpdir/paths.tch" "$key")" - printf '«%q» -> «%q»\n' "$key" "$val" - done > "$tmpdir/paths-actual.txt" - - printf '«%q» -> «%q»\n' \ - BAR "$PWD/toru.d/libre/split-base" \ - BAZ "$PWD/toru.d/libre/split-base" \ - FOO "$PWD/toru.d/libre/split-base" \ - bar "$PWD/toru.d/libre/split" \ - baz "$PWD/toru.d/libre/split" \ - foo "$PWD/toru.d/libre/split" \ - simple "$PWD/toru.d/libre/simple" \ - split-base "$PWD/toru.d/libre/split-base" \ - > "$tmpdir/paths-expected.txt" - - diff "$tmpdir/paths-expected.txt" "$tmpdir/paths-actual.txt" -} - -it_sets_torupath() { - cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot - TORUPATH=${tmpdir@Q} - REPOS=(libre) - eot - cat >> "$HOME/.abs.conf" <<-eot - ABSROOT=${PWD@Q}/toru.d - eot - - mkdir -p "$tmpdir/x" - T="$tmpdir/x" toru-path - test -f "$tmpdir/x/paths.tch" - not test -e "$tmpdir/paths.tch" -} diff --git a/test/toru.d/libre/simple/PKGBUILD b/test/toru.d/libre/simple/PKGBUILD deleted file mode 100644 index e2d44d1..0000000 --- a/test/toru.d/libre/simple/PKGBUILD +++ /dev/null @@ -1,11 +0,0 @@ -pkgname='simple' -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) - -package() { - : -} diff --git a/test/toru.d/libre/split-base/PKGBUILD b/test/toru.d/libre/split-base/PKGBUILD deleted file mode 100644 index ce547c5..0000000 --- a/test/toru.d/libre/split-base/PKGBUILD +++ /dev/null @@ -1,20 +0,0 @@ -pkgbase=split-base -pkgname=(FOO BAR BAZ) -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) - -package_FOO() { - : -} - -package_BAR() { - : -} - -package_BAZ() { - : -} diff --git a/test/toru.d/libre/split/PKGBUILD b/test/toru.d/libre/split/PKGBUILD deleted file mode 100644 index fe25a94..0000000 --- a/test/toru.d/libre/split/PKGBUILD +++ /dev/null @@ -1,19 +0,0 @@ -pkgname=(foo bar baz) -pkgver=1.0 -license=('GPL') -url='https://parabola.nu' - -pkgrel=1 -arch=(any) - -package_foo() { - : -} - -package_bar() { - : -} - -package_baz() { - : -} -- cgit v1.2.2