diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 2 | ||||
-rw-r--r-- | tests/lib | 6 | ||||
-rw-r--r-- | tests/lib-restricts | 13 | ||||
-rwxr-xr-x | tests/list-tests | 43 | ||||
-rwxr-xr-x | tests/tests/dsd-clone-drs | 11 |
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) @@ -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 |