diff options
Diffstat (limited to 'test/librelib-test.sh')
-rw-r--r-- | test/librelib-test.sh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/librelib-test.sh b/test/librelib-test.sh new file mode 100644 index 0000000..24c4478 --- /dev/null +++ b/test/librelib-test.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env roundup + +describe librelib + +. ./test-common.sh + +before() { + _before +} + +after() { + _after +} + +it_displays_help_and_fails_with_0_args() { + ret=0 + librelib >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? + + empty $tmpdir/stdout + [[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]] + [[ $ret != 0 ]] +} + +it_fails_with_2_args() { + ret=0 + librelib a b >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $ret != 0 ]] +} + +it_displays_usage_text() { + librelib -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +# Nothing in $(libdir) should be executable anymore (except that +# $(libexecdir)=$(libdir), and executable things go in there. But I +# digress, libremessages should not be executable anymore). +it_finds_messages() { + v1=$(librelib messages) + v2=$(librelib libremessages) + v3=$(librelib messages.sh) + v4=$(librelib libremessages.sh) + + [[ -r "$v1" && ! -x "$v1" ]] + [[ "$v1" == "$v2" ]] + [[ "$v1" == "$v3" ]] + [[ "$v1" == "$v4" ]] +} + +# conf.sh is non-executable +it_finds_conf() { + v1=$(librelib conf) + v2=$(librelib libreconf) + v3=$(librelib conf.sh) + v4=$(librelib libreconf.sh) + + [[ -r "$v1" && ! -x "$v1" ]] + [[ "$v1" == "$v2" ]] + [[ "$v1" == "$v3" ]] + [[ "$v1" == "$v4" ]] +} + +it_fails_to_find_phony() { + ret=0 + librelib phony >$tmpdir/stdout 2>$tmpdir/stderr || ret=$? + + empty $tmpdir/stdout + not empty $tmpdir/stderr + [[ $ret != 0 ]] +} |