summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-01 16:46:15 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-05 20:01:05 -0600
commitfbed0b50c73f1ed06bc47d490ce8ab78428c8e78 (patch)
treee89bead95bed60de8308837ce534445e5b38d385 /test
parent0b2139ee355ca73b9ddfeebf8c3881ce4f1c22c1 (diff)
add a few tests for libremakepkg
Diffstat (limited to 'test')
-rw-r--r--test/libremakepkg-test.sh41
-rw-r--r--test/libremakepkg.d/PKGBUILD-hello19
2 files changed, 60 insertions, 0 deletions
diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh
new file mode 100644
index 0000000..5ea3b59
--- /dev/null
+++ b/test/libremakepkg-test.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env roundup
+
+describe libremakepkg
+
+before() {
+ tmpdir=$(mktemp -d --tmpdir test-libremakepkg.XXXXXXXXXXXX)
+ mkdir -p "$XDG_CONFIG_HOME"/libretools
+ echo "CHROOTDIR='$tmpdir/chrootdir'" > "$XDG_CONFIG_HOME"/libretools/chroot.conf
+ stat=0
+}
+
+after() {
+ rm -rf -- "$tmpdir" "$XDG_CONFIG_HOME"
+}
+
+it_builds_a_trivial_package() {
+ cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
+ cd "$tmpdir"
+
+ sudo libremakepkg &>/dev/null
+ [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]]
+}
+
+it_displays_help_as_normal_user() {
+ libremakepkg -h >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
+}
+
+it_otherwise_fails_as_normal_user() {
+ # I do this to give it a chance of passing
+ cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD"
+ cd "$tmpdir"
+
+ libremakepkg >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
diff --git a/test/libremakepkg.d/PKGBUILD-hello b/test/libremakepkg.d/PKGBUILD-hello
new file mode 100644
index 0000000..706cb24
--- /dev/null
+++ b/test/libremakepkg.d/PKGBUILD-hello
@@ -0,0 +1,19 @@
+pkgname='libretools-hello'
+pkgver=1.0
+license=('GPL')
+url='https://parabolagnulinux.org'
+
+pkgrel=1
+arch=(any)
+depends=(sh)
+
+build() {
+ cd "$srcdir"
+ echo '#!/bin/sh' > hello.sh
+ echo 'echo Hello, world!' >> hello.sh
+}
+
+package() {
+ cd "$srcdir"
+ install -Dm755 hello.sh "$pkgdir"/usr/bin/libretools-hello
+}