chiark / gitweb /
test suite: Add DEBORIG pseudo-dependency
[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                 DEBORIG) gencontrol-add-deps \
68                         devscripts libdpkg-perl \
69                         libgit-wrapper-perl liblist-compare-perl \
70                         # NB git-deborig is not compatible with
71                         #  t-tstunt-parsechangelog
72                         ;;
73                 *) gencontrol-add-deps "$dep" ;;
74                 esac
75         done
76 }
77
78 test-done-gencontrol () {
79         stanza=$(
80                 add_Depends="$dependencies" \
81                 perl <debian/tests/control.in -wpe '
82                         if (/^(\w+):/) {
83                                 my $h = $1;
84                                 s{$}{ $ENV{"add_$h"} // "" }e;
85                         }
86                 ' 
87                 case "$restrictions" in
88                 ?*) echo "Restrictions:$restrictions" ;;
89                 esac
90                 )
91         key=$(printf "%s" "$stanza" | sha256sum)
92         key=${key%% *}
93         eval "
94                 stanza_$key=\"\$stanza\"
95                 tests_$key+=\" \${t#tests/tests/}\"
96         "
97         keys=" ${keys/ $key /}"
98         keys+=" $key "
99 }
100
101 finish-gencontrol () {
102         for key in $keys; do
103                 eval "
104                         stanza=\$stanza_$key
105                         tests=\$tests_$key
106                 "
107                 printf "Tests:%s\n%s\n\n" "$tests" "$stanza"
108         done
109 }
110
111 seddery () {
112         local seddery=$1
113         sed <$t -n '
114                 20q;
115                 /^: t-enumerate-tests-end$/q;
116                 '"$seddery"'
117         '
118 }
119
120 for t in $(run-parts --list tests/tests); do
121         test-begin-$mode
122         for r in $(seddery 's/^t-restrict //p'); do
123                 restriction-$mode
124         done
125         for deps in $(seddery 's/^t-dependencies //p'); do
126                 dependencies-$mode
127         done
128         test-done-$mode
129 done
130
131 finish-$mode