summaryrefslogtreecommitdiff
path: root/test/pkgbuild-check-nonfree-test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/pkgbuild-check-nonfree-test.sh')
-rw-r--r--test/pkgbuild-check-nonfree-test.sh66
1 files changed, 66 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..703733a
--- /dev/null
+++ b/test/pkgbuild-check-nonfree-test.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env roundup
+
+# avoid carpel tunnel
+pcn=pkgbuild-check-nonfree
+
+describe $pcn
+
+before() {
+ tmpdir=$(mktemp -d --tmpdir test-pkgbuild-check-nonfree.XXXXXXXXXXXX)
+ stat=0
+ local blacklist=$XDG_CACHE_HOME/libretools/blacklist.txt
+ mkdir -p "${blacklist%/*}"
+ echo 'linux:linux-libre:nonfree blobs and firmwares' >$blacklist
+ echo 'skype' >>$blacklist
+}
+
+after() {
+ rm -rf -- "$tmpdir" "$XDG_CACHE_HOME" "$XDG_CONFIG_HOME"
+}
+
+it_displays_usage_text() {
+ # This test seems silly, but it makes sure that it is executable,
+ # syntactically correct, and loading libraries works.
+ $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.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.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.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='http://phony'" >$XDG_CONFIG_HOME/libretools.conf
+ rm $XDG_CACHE_HOME/libretools/blacklist.txt
+
+ $pcn $pcn.PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+ [[ $stat != 0 ]] && [[ $stat != 15 ]]
+}