runtest: correctly pass shell option also for TAP tests
[platform/upstream/automake.git] / Makefile.am
index b745721..5aa543e 100644 (file)
@@ -345,11 +345,6 @@ AM_TESTS_ENVIRONMENT = \
   ; do \
     eval test x"\$${$$v}" = x || unset $$v; \
   done;
-# The 'AM_TESTS_REEXEC=no' setting tells the tests not to needlessly
-# re-execute themselves with the shell detected at configure time, since
-# we are already running them under it explicitly in our setup (see e.g.
-# the definition of TEST_LOG_COMPILER above).
-AM_TESTS_ENVIRONMENT += AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC;
 # We want warning messages and explanations for skipped tests to go to
 # the console if possible, so set up 'stderr_fileno_' properly.
 AM_TESTS_FD_REDIRECT = 9>&2
@@ -405,6 +400,17 @@ defs-static: defs-static.in Makefile
 EXTRA_DIST += defs-static.in
 CLEANFILES += defs-static
 
+runtest: runtest.in Makefile
+       $(AM_V_at)rm -f $@ $@-t
+       $(AM_V_GEN)in=runtest.in \
+         && $(MKDIR_P) t/ax \
+         && $(do_subst) <$(srcdir)/runtest.in >$@-t \
+         && chmod a+x $@-t
+       $(generated_file_finalize)
+EXTRA_DIST += runtest.in
+CLEANFILES += runtest
+noinst_SCRIPTS = runtest
+
 # If two test scripts have the same basename, they will end up sharing
 # the same log file, leading to all sort of undefined and undesired
 # behaviours.
@@ -420,6 +426,41 @@ check-no-repeated-test-name:
 check-local: check-no-repeated-test-name
 .PHONY: check-no-repeated-test-name
 
+# Check that our test cases are syntactically correct.
+# See automake bug#11898.
+check-tests-syntax:
+       @st=0; \
+       err () { echo "$@: $$*" >&2; st=1; }; \
+## The user might do something like "make check TESTS=t/foo" or
+## "make check TESTS_LOGS=t/foo.log" and expect (say) the test
+## 't/foo.sh' to be run; this has worked well until today, and
+## we want to continue supporting this use case.
+       bases=`for log in : $(TEST_LOGS); do echo $$log; done \
+         | sed -e '/^:$$/d' -e 's/\.log$$//'`; \
+       for bas in $$bases; do \
+         for suf in sh tap pl; do \
+           tst=$$bas.$$suf; \
+## Emulate VPATH search.
+           if test -f $$tst; then \
+             break; \
+           elif test -f $(srcdir)/$$tst; then \
+             tst=$(srcdir)/$$tst; \
+             break; \
+           else \
+             tst=''; \
+           fi; \
+         done; \
+         test -n "$$tst" || err "couldn't find test '$$bas'"; \
+## Don't check that perl tests are valid shell scripts!
+         test $$suf = pl && continue; \
+         $(AM_V_P) && echo " $(AM_TEST_RUNNER_SHELL) -n $$tst"; \
+         $(AM_TEST_RUNNER_SHELL) -n "$$tst" \
+           || err "test '$$tst' syntactically invalid"; \
+       done; \
+       exit $$st
+check-local: check-tests-syntax
+.PHONY: check-tests-syntax
+
 ## Checking the list of tests.
 test_subdirs = t t/pm t/perf
 include $(srcdir)/t/CheckListOfTests.am