diff options
Diffstat (limited to 'test/pkgbuild-check-nonfree-test.sh')
-rw-r--r-- | test/pkgbuild-check-nonfree-test.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/pkgbuild-check-nonfree-test.sh b/test/pkgbuild-check-nonfree-test.sh new file mode 100644 index 0000000..d547e24 --- /dev/null +++ b/test/pkgbuild-check-nonfree-test.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env roundup + +# avoid carpel tunnel +pcn=pkgbuild-check-nonfree + +describe $pcn + +. ./test-common.sh + +before() { + _before + + mkdir -p $XDG_CONFIG_HOME/libretools + echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf + + local blacklist=$XDG_CACHE_HOME/libretools/blacklist.txt + mkdir -p "${blacklist%/*}" + echo 'linux:linux-libre:nonfree blobs and firmwares' >$blacklist + echo 'skype' >>$blacklist +} + +after() { + _after +} + +it_displays_usage_text() { + # This test seems silly, but it makes sure that it is executable, + # syntactically correct, and loading libraries works. + LANG=C $pcn -h >$tmpdir/stdout 2>$tmpdir/stderr + stat=$? + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + [[ -z "$(cat $tmpdir/stderr)" ]] + [[ $stat == 0 ]] +} + +it_succeeds_for_free_depends() { + $pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ -z "$(cat $tmpdir/stdout)" ]] + [[ -n "$(cat $tmpdir/stderr)" ]] + [[ $stat == 0 ]] +} + +it_succeeds_for_nonfree_depend_with_replacement() { + $pcn $pcn.d/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ -z "$(cat $tmpdir/stdout)" ]] + [[ -n "$(cat $tmpdir/stderr)" ]] + [[ $stat == 0 ]] +} + +it_fails_with_15_for_nonfree_depend() { + $pcn $pcn.d/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ -z "$(cat $tmpdir/stdout)" ]] + [[ -n "$(cat $tmpdir/stderr)" ]] + [[ $stat == 15 ]] +} + +it_fails_when_there_is_no_blacklist() { + mkdir -p $XDG_CONFIG_HOME/libretools + echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf + rm $XDG_CACHE_HOME/libretools/blacklist.txt + + $pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ -z "$(cat $tmpdir/stdout)" ]] + [[ -n "$(cat $tmpdir/stderr)" ]] + [[ $stat != 0 ]] && [[ $stat != 15 ]] +} |