summaryrefslogtreecommitdiff
path: root/test/librexgettext-test.sh
blob: f9a00319a8a8aaa4f3e71889540a2e5ba2fb164a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
}