chiark / gitweb /
Test suite: Implement list-tests gencontrol
[dgit.git] / tests / list-tests
index 21f96b4..d0582f6 100755 (executable)
@@ -30,6 +30,45 @@ 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
+}
+
 for t in $(run-parts --list tests/tests); do
        test-begin-$mode
        for r in $(sed <$t -n '
@@ -41,3 +80,5 @@ for t in $(run-parts --list tests/tests); do
        done
        test-done-$mode
 done
+
+finish-$mode