chiark / gitweb /
test suite: editing a test script overrides DGIT_TESTS_PROGRESSIVE.
[dgit.git] / tests / Makefile
index 011bd3c..88bc0a0 100644 (file)
@@ -1,14 +1,24 @@
 # usage: tests/using-intree make -f tests/Makefile
-# (optionally setting TESTSCRIPTS='tests/tests/foo tests/tests/bar')
+# optionally setting
+#   TESTSCRIPTS='tests/tests/foo tests/tests/bar')
+#   DGIT_TEST_RETRY_COUNT=<a smallish integer>
 
-TESTSCRIPTS ?= $(shell run-parts --list tests/tests)
+TESTSCRIPTS ?= $(shell tests/enumerate-tests)
 TESTNAMES := $(notdir $(TESTSCRIPTS))
 
 all: $(foreach t,$(TESTNAMES),tests/tmp/$t.ok)
-       @echo "ALL PASSED"
+       @echo "ALL PASSED$${DGIT_TESTS_PROGRESSIVE+ AT SOME POINT}"
 
-tests/tmp:
-       mkdir -p $@
-
-tests/tmp/%.ok: tests/tmp
+tests/tmp/%.ok: tests/tests/%
+ifeq ($(DGIT_TEST_RETRY_COUNT),)
        tests/tests/$* >tests/tmp/$*.log 2>&1
+else
+       @for retry in $$( seq 1 $(DGIT_TEST_RETRY_COUNT) ); do          \
+               echo "[$$retry] $*";                                    \
+               tests/tests/$* >tests/tmp/$*.$$retry.log 2>&1;          \
+               rc=$$?;                                                 \
+               if [ $$rc = 0 ]; then exit 0; fi;                       \
+               echo >&2 "[$$retry] $* TEST FAILED $$rc";               \
+       done; exit $$rc
+endif
+       @touch $@