chiark / gitweb /
Test suite: list-tests: Break out seddery()
[dgit.git] / tests / list-tests
index 21f96b47b0ccf3efa396aff69f30be822f7c459d..3381dbfa08e581ea9b7242e6f740d03af6c7a945 100755 (executable)
@@ -30,14 +30,60 @@ test-done- () {
        esac
 }
 
+finish- () {
+       :
+}
+
+test-begin-gencontrol () {
+       restrictions=''
+}
+
+restriction-gencontrol () {
+       restrictions+=" $r"
+}
+
+test-done-gencontrol () {
+       stanza=$(
+               sed <debian/tests/control.in ''
+               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
        test-done-$mode
 done
+
+finish-$mode