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