chiark / gitweb /
po/README: Mention -k10 threshold
[dgit.git] / tests / enumerate-tests
1 #!/bin/bash
2
3 set -e
4
5 . tests/lib-core
6 . tests/lib-restricts
7
8 mode=$1
9
10 test-begin- () {
11         whynots=''
12 }
13
14 restriction- () {
15         set +e
16         whynot=$(t-restriction-$r)
17         rc=$?
18         whynot="${whynot//
19 / / }"
20         set -e
21         case "$rc.$whynot" in
22         0.)     ;;
23         1.?*)   whynots="$whynots${whynots:+; }$whynot" ;;
24         *)      fail "restriction $r for $t gave $rc $whynot !"
25         esac
26 }
27
28 dependencies- () {
29         :
30 }
31
32 test-done- () {
33         case "$whynots" in
34         '')     echo $t ;;
35         ?*)     echo >&2 "SKIP $t $whynots" ;;
36         esac
37 }
38
39 finish- () {
40         :
41 }
42
43 test-begin-gencontrol () {
44         restrictions=''
45         dependencies='dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc, faketime'
46 }
47
48 restriction-gencontrol () {
49         if [ $r = x-dgit-out-of-tree-only ]; then return; fi
50         restrictions+=" $r"
51 }
52
53 gencontrol-add-deps () {
54         for dep in "$@"; do
55                 dependencies+="${dependencies:+, }$dep"
56         done
57 }
58
59 dependencies-gencontrol () {
60         for dep in "$deps"; do
61                 case "$dep" in
62                 NO-DGIT) dependencies='chiark-utils-bin, faketime' ;;
63                 NO-DEFAULT) dependencies='' ;;
64                 GDR) gencontrol-add-deps \
65                         git-debrebase git-buildpackage
66                         ;;
67                 *) gencontrol-add-deps "$dep" ;;
68                 esac
69         done
70 }
71
72 test-done-gencontrol () {
73         stanza=$(
74                 add_Depends="$dependencies" \
75                 perl <debian/tests/control.in -wpe '
76                         if (/^(\w+):/) {
77                                 my $h = $1;
78                                 s{$}{ $ENV{"add_$h"} // "" }e;
79                         }
80                 ' 
81                 case "$restrictions" in
82                 ?*) echo "Restrictions:$restrictions" ;;
83                 esac
84                 )
85         key=$(printf "%s" "$stanza" | sha256sum)
86         key=${key%% *}
87         eval "
88                 stanza_$key=\"\$stanza\"
89                 tests_$key+=\" \${t#tests/tests/}\"
90         "
91         keys=" ${keys/ $key /}"
92         keys+=" $key "
93 }
94
95 finish-gencontrol () {
96         for key in $keys; do
97                 eval "
98                         stanza=\$stanza_$key
99                         tests=\$tests_$key
100                 "
101                 printf "Tests:%s\n%s\n\n" "$tests" "$stanza"
102         done
103 }
104
105 seddery () {
106         local seddery=$1
107         sed <$t -n '
108                 20q;
109                 /^: t-enumerate-tests-end$/q;
110                 '"$seddery"'
111         '
112 }
113
114 for t in $(run-parts --list tests/tests); do
115         test-begin-$mode
116         for r in $(seddery 's/^t-restrict //p'); do
117                 restriction-$mode
118         done
119         for deps in $(seddery 's/^t-dependencies //p'); do
120                 dependencies-$mode
121         done
122         test-done-$mode
123 done
124
125 finish-$mode