chiark / gitweb /
Test suite: Honour DGIT_TEST_DEBUG=''.
[dgit.git] / tests / list-tests
index 21f96b47b0ccf3efa396aff69f30be822f7c459d..8578fe60386528f57f3b65495d1b87f94cb5dcb6 100755 (executable)
@@ -23,6 +23,10 @@ restriction- () {
        esac
 }
 
+dependencies- () {
+       :
+}
+
 test-done- () {
        case "$whynots" in
        '')     echo $t ;;
@@ -30,14 +34,74 @@ test-done- () {
        esac
 }
 
+finish- () {
+       :
+}
+
+test-begin-gencontrol () {
+       restrictions=''
+       dependencies=''
+}
+
+restriction-gencontrol () {
+       restrictions+=" $r"
+}
+
+dependencies-gencontrol () {
+       dependencies+=", $deps"
+}
+
+test-done-gencontrol () {
+       stanza=$(
+               add_Depends="$dependencies" \
+               perl <debian/tests/control.in -wpe '
+                       if (/^(\w+):/) {
+                               my $h = $1;
+                               s{$}{ $ENV{"add_$h"} // "" }e;
+                       }
+               ' 
+               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
+}
+
+seddery () {
+       local seddery=$1
+       sed <$t -n '
+               20q;
+               /^: t-list-tests-end$/q;
+               '"$seddery"'
+       '
+}
+
 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
+       for r in $(seddery 's/^t-restrict //p'); do
                restriction-$mode
        done
+       for deps in $(seddery 's/^t-dependencies //p'); do
+               dependencies-$mode
+       done
        test-done-$mode
 done
+
+finish-$mode