chiark / gitweb /
Test suite: Implement list-tests gencontrol
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2015 17:17:55 +0000 (18:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2015 17:32:29 +0000 (18:32 +0100)
debian/tests/control.in [new file with mode: 0644]
tests/list-tests

diff --git a/debian/tests/control.in b/debian/tests/control.in
new file mode 100644 (file)
index 0000000..62ff3ee
--- /dev/null
@@ -0,0 +1,2 @@
+Tests-Directory: tests/tests
+Depends: dgit, dgit-infrastructure, devscripts, rsync
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