summaryrefslogtreecommitdiff
path: root/test/pkgbuild-check-nonfree-test.sh
blob: 80bfc476669b001e5c3da96edeb8659d3d4fee6e (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
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env roundup

# avoid carpel tunnel
pcn=pkgbuild-check-nonfree

describe $pcn

. ./test-common.sh

before() {
	_before

	mkdir -p $XDG_CONFIG_HOME/libretools
	echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf

	local blacklist=$XDG_CACHE_HOME/libretools/blacklist.txt
	mkdir -p "${blacklist%/*}"
	echo 'linux:linux-libre:nonfree blobs and firmwares' >$blacklist
	echo 'skype' >>$blacklist
}

after() {
	_after
}

it_displays_usage_text() {
	# This test seems silly, but it makes sure that it is executable,
	# syntactically correct,  and loading libraries works.
	LANG=C $pcn -h >$tmpdir/stdout 2>$tmpdir/stderr
	stat=$?

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

it_succeeds_for_free_depends() {
	$pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?

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

it_succeeds_for_nonfree_depend_with_replacement() {
	$pcn $pcn.d/PKGBUILD.nonfree-replacement >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?

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

it_fails_with_15_for_nonfree_depend() {
	$pcn $pcn.d/PKGBUILD.nonfree >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?

	empty $tmpdir/stdout
	! empty $tmpdir/stderr
	[[ $stat == 15 ]]
}

it_fails_when_there_is_no_blacklist() {
	mkdir -p $XDG_CONFIG_HOME/libretools
	echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf
	rm $XDG_CACHE_HOME/libretools/blacklist.txt

	$pcn $pcn.d/PKGBUILD.free >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?

	empty $tmpdir/stdout
	! empty $tmpdir/stderr
	[[ $stat != 0 ]] && [[ $stat != 15 ]]
}