diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-07-11 10:51:15 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-07-13 12:56:47 +0200 |
commit | 9df354ac9834f319c1faeef11748b7f1f7afdfae (patch) | |
tree | 2d7e80997097e1684b47902a1bedf25a13ca17b2 /Makefile.am | |
parent | 65e7ac8c3556d1895ee597811856710143cfc4ac (diff) | |
download | automake-9df354ac9834f319c1faeef11748b7f1f7afdfae.tar.gz |
tests: verify the shell test scripts are syntactically valid
Fixes automake bug#11898.
This measure of extra safety is mostly motivated by the fact that some
shells (at least some versions of Bash in the 3.x release series, one
of which serves as /bin/sh on Mac OS X 10.7, as well as Bash 4.0 and the
/usr/xpg4/bin/sh shell from Solaris 10) erroneously exit with exit status
0 upon encountering a syntax error, if an exit trap is sett (as it is in
our test scripts).
* Makefile.am (check-tests-syntax): New, check that the shell test
scripts listed in $(TESTS) are syntactically correct.
(.PHONY, check-local): Depend on it.
* t/self-check-exit.tap : Remove checks verifying that a script exits
with non-zero status upon encountering a syntax error; as explained
above, we can't depend on that.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'Makefile.am')
-rw-r--r-- | Makefile.am | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 276448158..5aa543e9c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -426,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 |