summaryrefslogtreecommitdiff
path: root/tests/list-tests
blob: d0582f65a93ac86b8eabfde404c1f5b1ec472063 (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
75
76
77
78
79
80
81
82
83
84
#!/bin/bash

set -e

. tests/lib-core
. tests/lib-restricts

mode=$1

test-begin- () {
	whynots=''
}

restriction- () {
	set +e
	whynot=$(t-restriction-$r)
	rc=$?
	set -e
	case "$rc.$whynot" in
	0.)	;;
	1.?*)	whynots="$whynots${whynots:+; }$whynot" ;;
	*)	fail "restriction $r for $t gave $rc $whynot !"
	esac
}

test-done- () {
	case "$whynots" in
	'')	echo $t ;;
	?*)	echo >&2 "SKIP $t $whynots" ;;
	esac
}

finish- () {
	:
}

test-begin-gencontrol () {
	restrictions=''
}

restriction-gencontrol () {
	restrictions+=" $r"
}

test-done-gencontrol () {
	stanza=$(
		sed <debian/tests/control.in ''
		case "$restrictions" in
		?*) echo "Restrictions:$restrictions" ;;
		esac
		)
	key=$(printf "%s" "$stanza" | sha256sum)
	key=${key%% *}
	eval "
		stanza_$key=\"\$stanza\"
		tests_$key+=\" \${t#tests/tests/}\"
	"
	keys=" ${keys/ $key /}"
	keys+=" $key "
}

finish-gencontrol () {
	for key in $keys; do
		eval "
			stanza=\$stanza_$key
			tests=\$tests_$key
		"
		printf "Tests:%s\n%s\n\n" "$tests" "$stanza"
	done
}

for t in $(run-parts --list tests/tests); do
	test-begin-$mode
	for r in $(sed <$t -n '
		20q;
		/^: t-list-tests-end$/q;		
		s/^t-restrict //p
	'); do
		restriction-$mode
	done
	test-done-$mode
done

finish-$mode