summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2015-07-25 17:36:18 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2015-07-25 18:32:29 +0100
commitada48ca013e77d7e821d326db40bc1a59ba639ea (patch)
tree795d0bcac6795fcf7168e1e60a88186ddba383f4 /tests
parent417bcf4ea06b9e181c39734e121d9a32cf7cbb21 (diff)
Test suite: Introduce tests/list-tests
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile2
-rw-r--r--tests/lib6
-rw-r--r--tests/lib-restricts13
-rwxr-xr-xtests/list-tests43
-rwxr-xr-xtests/tests/dsd-clone-drs11
5 files changed, 65 insertions, 10 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 011bd3c..157b487 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,7 +1,7 @@
# usage: tests/using-intree make -f tests/Makefile
# (optionally setting TESTSCRIPTS='tests/tests/foo tests/tests/bar')
-TESTSCRIPTS ?= $(shell run-parts --list tests/tests)
+TESTSCRIPTS ?= $(shell tests/list-tests)
TESTNAMES := $(notdir $(TESTSCRIPTS))
all: $(foreach t,$(TESTNAMES),tests/tmp/$t.ok)
diff --git a/tests/lib b/tests/lib
index e81a62a..d131e7b 100644
--- a/tests/lib
+++ b/tests/lib
@@ -5,6 +5,7 @@ set -x
set -o pipefail
. tests/lib-core
+. tests/lib-restricts
t-set-intree
@@ -596,6 +597,11 @@ t-policy-periodic () {
test-dummy $drs_dispatch '' --cron
}
+t-restrict () {
+ local restriction=$1
+ (cd $root; t-restriction-$restriction >&2)
+}
+
t-chain-test () {
local ct=$1
local d=${0%/*}
diff --git a/tests/lib-restricts b/tests/lib-restricts
new file mode 100644
index 0000000..aca6692
--- /dev/null
+++ b/tests/lib-restricts
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+t-restriction-x-dgit-intree-only () {
+ if [ "x$DGIT_TEST_INTREE" != x ]; then return 0; fi
+ echo 'running installed package version'
+ return 1
+}
+
+t-restriction-x-dgit-git-only () {
+ if test -d .git; then return 0; fi
+ echo 'not running out of git clone'
+ return 1
+}
diff --git a/tests/list-tests b/tests/list-tests
new file mode 100755
index 0000000..21f96b4
--- /dev/null
+++ b/tests/list-tests
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+set -e
+
+. tests/lib-core
+. tests/lib-restricts
+
+mode=$1
+
+test-begin- () {
+ whynots=''
+}
+
+restriction- () {
+ set +e
+ whynot=$(t-restriction-$r)
+ rc=$?
+ set -e
+ case "$rc.$whynot" in
+ 0.) ;;
+ 1.?*) whynots="$whynots${whynots:+; }$whynot" ;;
+ *) fail "restriction $r for $t gave $rc $whynot !"
+ esac
+}
+
+test-done- () {
+ case "$whynots" in
+ '') echo $t ;;
+ ?*) echo >&2 "SKIP $t $whynots" ;;
+ esac
+}
+
+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
+ restriction-$mode
+ done
+ test-done-$mode
+done
diff --git a/tests/tests/dsd-clone-drs b/tests/tests/dsd-clone-drs
index aa162bb..16bfa2e 100755
--- a/tests/tests/dsd-clone-drs
+++ b/tests/tests/dsd-clone-drs
@@ -2,15 +2,8 @@
set -e
. tests/lib
-if [ "x$DGIT_TEST_INTREE" = x ]; then
- echo >&2 'running installed package version, cannot test self-clone'
- exit 0
-fi
-
-if ! test -d $root/.git; then
- echo >&2 'not running out of git clone, cannot test self-clone'
- exit 0
-fi
+t-restrict x-dgit-intree-only
+t-restrict x-dgit-git-only
t-dsd