From fbed0b50c73f1ed06bc47d490ce8ab78428c8e78 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 1 Jun 2013 16:46:15 -0600 Subject: add a few tests for libremakepkg --- test/libremakepkg-test.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/libremakepkg-test.sh (limited to 'test/libremakepkg-test.sh') 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)" ]] +} -- cgit v1.2.2