diff options
-rwxr-xr-x | src/librefetch/librefetch | 2 | ||||
-rw-r--r-- | test/librefetch-test.sh | 48 | ||||
-rw-r--r-- | test/librefetch.d/PKGBUILD | 15 | ||||
-rw-r--r-- | test/librefetch.d/list.txt | 2 |
4 files changed, 66 insertions, 1 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 62cfb42..93bcd1e 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -226,7 +226,7 @@ makepkg_modify=' } /download_sources\(\) \{/ { - arm -rf "$srcdir" + arm -rf "$srcdir"\nmkdir "$srcdir" } s|srcdir=.*|&-libre| diff --git a/test/librefetch-test.sh b/test/librefetch-test.sh new file mode 100644 index 0000000..7408993 --- /dev/null +++ b/test/librefetch-test.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env roundup + +describe librefetch + +. ./test-common.sh + +before() { + _before + + mkdir -p "$HOME" + printf '%s\n' \ + "DLAGENTS+=(\"libre::$(which librefetch) -p \\\"\\\$BUILDFILE\\\" %u %o\")" \ + 'BUILDDIR=""' \ + > "$HOME/.makepkg.conf" + + mkdir -p "$XDG_CONFIG_HOME/libretools" + printf '%s\n' \ + 'MIRROR="phony://example.com/dir/"' \ + 'DOWNLOADER=/usr/bin/false' \ + > "$XDG_CONFIG_HOME/libretools/librefetch.conf" +} + +after() { + _after +} + +it_displays_help() { + LANG=C librefetch -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_cleans_src_libre_first() { + cp librefetch.d/* "$tmpdir/" + cd "$tmpdir" + + # create garbage + mkdir -p src-libre/foo + touch src-libre/foo/file + + # run librefetch + makepkg -g + + srcball=src/testpkg-1.0.tar.gz + bsdtar tf "$srcball" > list-pkg.txt + diff -u list.txt list-pkg.txt +} diff --git a/test/librefetch.d/PKGBUILD b/test/librefetch.d/PKGBUILD new file mode 100644 index 0000000..723d82e --- /dev/null +++ b/test/librefetch.d/PKGBUILD @@ -0,0 +1,15 @@ +pkgname=testpkg +pkgver=1.0 +pkgrel=1 +pkgdesc=foo +arch=(any) +source=("libre://$pkgname-$pkgver.tar.gz") + +mksource() { + mkdir "$srcdir/bar" + touch "$srcdir/bar/file" +} + +package() { + :; +} diff --git a/test/librefetch.d/list.txt b/test/librefetch.d/list.txt new file mode 100644 index 0000000..b04d5d1 --- /dev/null +++ b/test/librefetch.d/list.txt @@ -0,0 +1,2 @@ +bar/ +bar/file |