summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 01:32:55 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-27 01:32:55 -0400
commitb0b29df10764cecee365815476d83641e668b408 (patch)
treea209aabcda0c925b05f9a745679492dc35452bbf
parentf6ccc7caa1d80c7a2fcc6486f872d54468d265dc (diff)
Add (roundup-based) unit-test framework, tests for pkgbuild-check-nonfree
-rw-r--r--Makefile2
-rw-r--r--test/pkgbuild-check-nonfree-test.sh66
-rw-r--r--test/pkgbuild-check-nonfree.PKGBUILD.free18
-rw-r--r--test/pkgbuild-check-nonfree.PKGBUILD.nonfree18
-rw-r--r--test/pkgbuild-check-nonfree.PKGBUILD.nonfree-replacement18
-rwxr-xr-xtest/runtests23
6 files changed, 145 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index e5b38b1..928878b 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,8 @@ libretools-mips64el=mips64el-tools
all: PHONY build
build: PHONY build-libretools build-doc
install: PHONY install-libretools install-doc
+check:
+ @cd test && ./runtests
%-doc: PHONY doc
$(MAKE) -C doc $*
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 ]]
+}
diff --git a/test/pkgbuild-check-nonfree.PKGBUILD.free b/test/pkgbuild-check-nonfree.PKGBUILD.free
new file mode 100644
index 0000000..4b8f0dd
--- /dev/null
+++ b/test/pkgbuild-check-nonfree.PKGBUILD.free
@@ -0,0 +1,18 @@
+pkgname=wmii
+pkgver=3.9.2
+pkgrel=3
+pkgdesc="A small, dynamic window manager for X11"
+arch=('i686' 'x86_64')
+license=('MIT')
+url="http://wmii.suckless.org/"
+depends=('libxft' 'libxrandr' 'libxinerama' 'dash')
+source=()
+md5sums=()
+
+build() {
+ :
+}
+
+package() {
+ :
+}
diff --git a/test/pkgbuild-check-nonfree.PKGBUILD.nonfree b/test/pkgbuild-check-nonfree.PKGBUILD.nonfree
new file mode 100644
index 0000000..3a7afa4
--- /dev/null
+++ b/test/pkgbuild-check-nonfree.PKGBUILD.nonfree
@@ -0,0 +1,18 @@
+pkgname=wmii
+pkgver=3.9.2
+pkgrel=3
+pkgdesc="A small, dynamic window manager for X11"
+arch=('i686' 'x86_64')
+license=('MIT')
+url="http://wmii.suckless.org/"
+depends=('skype') # random non-free package with no other information
+source=()
+md5sums=()
+
+build() {
+ :
+}
+
+package() {
+ :
+}
diff --git a/test/pkgbuild-check-nonfree.PKGBUILD.nonfree-replacement b/test/pkgbuild-check-nonfree.PKGBUILD.nonfree-replacement
new file mode 100644
index 0000000..7855bdc
--- /dev/null
+++ b/test/pkgbuild-check-nonfree.PKGBUILD.nonfree-replacement
@@ -0,0 +1,18 @@
+pkgname=wmii
+pkgver=3.9.2
+pkgrel=3
+pkgdesc="A small, dynamic window manager for X11"
+arch=('i686' 'x86_64')
+license=('MIT')
+url="http://wmii.suckless.org/"
+depends=('linux') # random non-free package with a replacement
+source=()
+md5sums=()
+
+build() {
+ :
+}
+
+package() {
+ :
+}
diff --git a/test/runtests b/test/runtests
new file mode 100755
index 0000000..7410032
--- /dev/null
+++ b/test/runtests
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# Set up the install to work with
+destdir=$(mktemp --tmpdir -d libretools-test-destdir.XXXXXXXXXX)
+make -C .. install DESTDIR=$destdir &>/dev/null || {
+ echo 'error creating local install, cannot run tests'
+ exit 1
+}
+export PATH="$destdir/usr/bin:$destdir/usr/sbin:$PATH"
+export LIBRETOOLS_LIBDIR="$destdir/usr/lib/libretools"
+
+# Set up the user profile
+home=$(mktemp --tmpdir -d libretools-test-home.XXXXXXXXXX)
+export XDG_CACHE_HOME="$home/.cache"
+export XDG_CONFIG_HOME="$home/.config"
+
+# Run the tests
+roundup
+ret=$?
+
+# Clean up
+rm -rf -- "$destdir" "$testhome"
+exit $ret