diff options
Diffstat (limited to 'test/librexgettext-test.sh')
-rw-r--r-- | test/librexgettext-test.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/librexgettext-test.sh b/test/librexgettext-test.sh new file mode 100644 index 0000000..f9a0031 --- /dev/null +++ b/test/librexgettext-test.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env roundup + +describe librexgettext +. ./test-common.sh + +it_displays_help() { + LC_ALL=C librexgettext -h >$tmpdir/stdout 2>$tmpdir/stderr + + [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]] + empty $tmpdir/stderr +} + +it_fails_with_0_args() { + librexgettext >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ $stat != 0 ]] + empty $tmpdir/stdout + not empty $tmpdir/stderr +} + +passcase() { + librexgettext librexgettext.d/$roundup_test_name.sh > $tmpdir/actual.pot 2>$tmpdir/stderr + empty $tmpdir/stderr + diff -u librexgettext.d/$roundup_test_name.pot $tmpdir/actual.pot +} + +it_handles_multiple_skipped_flags() { passcase; } +it_handles_zero_flags() { passcase; } +it_handles_librefetch_flags() { passcase; } + +it_fails_on_missing_final_flag_description() { + librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || stat=$? + + [[ $stat != 0 ]] + [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4:"* ]] +} + + +it_fails_on_subshell_flag_descriptions() { + librexgettext librexgettext.d/$roundup_test_name.sh > /dev/null 2>$tmpdir/stderr || stat=$? + + [[ $stat != 0 ]] + [[ "$(sed 1q $tmpdir/stderr)" = "librexgettext.d/$roundup_test_name.sh:4-6:"* ]] +} + +it_doesnt_keep_failing() { + librexgettext some_file_that_doesnt_exist >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + + [[ $stat != 0 ]] + empty $tmpdir/stdout + [[ "$(wc -l <$tmpdir/stderr)" == 1 ]] +} + +it_handles_multiple_files() { + librexgettext librexgettext.d/combine1.sh librexgettext.d/combine2.sh > $tmpdir/actual.pot 2>$tmpdir/stderr + empty $tmpdir/stderr + diff -u librexgettext.d/combine.pot $tmpdir/actual.pot +} |