summaryrefslogtreecommitdiff
path: root/test/librefetch-test.sh
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-09-29 15:00:21 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-10-01 20:31:54 -0400
commitf2294c82afae36bbd5772a86c6689fd4c12c50f0 (patch)
tree76c4b79054cdc8d58430db4d932cb94ebe49e290 /test/librefetch-test.sh
parent872b692162a44307161aa98a3c5edaccc3c7b61a (diff)
(BATS) test: Move files around
But don't edit them yet. This directory structure is based on that of dbscripts.
Diffstat (limited to 'test/librefetch-test.sh')
-rw-r--r--test/librefetch-test.sh135
1 files changed, 0 insertions, 135 deletions
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
-}