aboutsummaryrefslogtreecommitdiff
blob: ebf0e810ee237f00e5f3b4c1db15e385524a6708 (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
72
73
74
#!/bin/bash

. ../init.sh || exit 1

set -e

export ROOT=${as}/root
export Q_VDB=/

mktmpdir

test() {
	local num=$1 exp=$2 ret
	local cmd=( qdepends "${@:3}" )

	"${cmd[@]}" >& list && ret=0 || ret=$?
	if [[ ${ret} -ne ${exp} ]] ; then
		tend 1 "exit code: wanted ${exp} but got ${ret}: ${cmd[*]}"
	elif [[ ${exp} -ne 0 ]] ; then
		# for errors, let the message be anything
		return
	fi

	# qdepends output is based on a hash, which may differ based on
	# endiannes, so sort the output so we get a deterministic set
	while IFS= read -r line ; do
		case "${line}" in
		*:*)
			pkg=${line%%:*}
			line=${line#*:}
			echo "${pkg}: $(echo "${line}" | tr ' ' '\n' | LC_ALL=C sort | xargs)"
			;;
		*)
			echo "${line}"
			;;
		esac
	done < list | diff list - | patch -s list

	local good="${as}/list${num}.good"
	if [[ ! -e ${good} ]] ; then
		cp list "${good}"
	fi
	diff -u list "${good}"
	tend $? "${num} ${cmd[*]}"
}

testf() { test "$1" "${3:-0}" -S "$2"; }

# basic sanity checks
testf 00 '|' 1
testf 01 ''
testf 02 'a/b'
testf 03 'foo? ( a/b )'
testf 04 '|| ( a/b )'

# a bit more complicated with or deps
testf 05 '|| ( || ( || ( x ) a ) )'

# hande use deps on atoms #470180
testf 06 'a[foo(+)]'

testQ() { test "$1" "${3:-0}" -Q "$2"; }

# reverse checks #504636
testQ 07 xinit

testq() { test "$1" "${3:-0}" -q "$2"; }

# forward checks #504636
testq 08 xdm

cleantmpdir

end