chiark / gitweb /
21f96b47b0ccf3efa396aff69f30be822f7c459d
[dgit.git] / tests / list-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         set -e
19         case "$rc.$whynot" in
20         0.)     ;;
21         1.?*)   whynots="$whynots${whynots:+; }$whynot" ;;
22         *)      fail "restriction $r for $t gave $rc $whynot !"
23         esac
24 }
25
26 test-done- () {
27         case "$whynots" in
28         '')     echo $t ;;
29         ?*)     echo >&2 "SKIP $t $whynots" ;;
30         esac
31 }
32
33 for t in $(run-parts --list tests/tests); do
34         test-begin-$mode
35         for r in $(sed <$t -n '
36                 20q;
37                 /^: t-list-tests-end$/q;                
38                 s/^t-restrict //p
39         '); do
40                 restriction-$mode
41         done
42         test-done-$mode
43 done