summaryrefslogtreecommitdiff
path: root/test/cases/librelib.bats
blob: 1bd80ae733802839a3ecb460689a8815ae9dfe00 (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
59
60
load ../lib/common

@test "librelib displays help and fails with 0 args" {
	librelib >$tmpdir/stdout 2>$tmpdir/stderr || status=$?

	empty $tmpdir/stdout
	[[ "$(sed 1q $tmpdir/stderr)" =~ Usage:.* ]]
	[[ $status != 0 ]]
}

@test "librelib fails with 2 args" {
	librelib a b >$tmpdir/stdout 2>$tmpdir/stderr || status=$?

	empty $tmpdir/stdout
	not empty $tmpdir/stderr
	[[ $status != 0 ]]
}

@test "librelib 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).
@test "librelib 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
@test "librelib 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" ]]
}

@test "librelib fails to find phony" {
	librelib phony >$tmpdir/stdout 2>$tmpdir/stderr || status=$?

	empty $tmpdir/stdout
	not empty $tmpdir/stderr
	[[ $status != 0 ]]
}