diff options
Diffstat (limited to 'test/pkgbuild-check-nonfree-test.sh')
-rw-r--r-- | test/pkgbuild-check-nonfree-test.sh | 78 |
1 files changed, 78 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..2af2669 --- /dev/null +++ b/test/pkgbuild-check-nonfree-test.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env roundup + +# avoid carpel tunnel +pcn=pkgbuild-check-nonfree +psn=pkgbuild-summarize-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. + LC_ALL=C $pcn -h >$tmpdir/stdout 2>$tmpdir/stderr + stat=$? + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr + [[ $stat == 0 ]] +} + +it_succeeds_for_free_depends() { + $pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $stat == 0 ]] +} + +it_succeeds_for_nonfree_depend_with_replacement() { + $pcn $pcn.d/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $stat == 0 ]] +} + +it_fails_for_nonfree_depend() { + $pcn $pcn.d/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + [[ $stat != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr + + local pcn_stat=$stat + + $psn $pcn_stat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + [[ $stat != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +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=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $stat != 0 ]] && [[ $stat != 15 ]] +} |