From: Stefano Lattarini Date: Sun, 28 Aug 2011 09:48:44 +0000 (+0200) Subject: testsuite: different test scripts cannot share the same basename X-Git-Tag: ng-0.5a~89^2~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59ad059649a33886456ddef11d66578e2b6e7dcd;p=thirdparty%2Fautomake.git testsuite: different test scripts cannot share the same basename 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. Add a Makefile check verifying that this is not the case. * tests/test-logs-repeated.test: New test, verifying previously unspecified semantics (in the definition of $(TEST_LOGS) from $(TESTS)) that we use in our new check. * tests/Makefile.am (TESTS): Update. (check-no-repeated-test-name): New .PHONY check. (check-local): Depend on it. --- diff --git a/ChangeLog b/ChangeLog index af6d0d4d7..8e4e6d744 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-08-28 Stefano Lattarini + + testsuite: different test scripts cannot share the same basename + 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. Add a Makefile check verifying that this + is not the case. + * tests/test-logs-repeated.test: New test, verifying previously + unspecified semantics (in the definition of $(TEST_LOGS) from + $(TESTS)) that we use in our new check. + * tests/Makefile.am (TESTS): Update. + (check-no-repeated-test-name): New .PHONY check. + (check-local): Depend on it. + 2011-08-26 Stefano Lattarini tests: fix spurious failure for awk implementation of TAP driver diff --git a/tests/Makefile.am b/tests/Makefile.am index aee597818..95d9efa29 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -770,6 +770,7 @@ test-driver-trs-suffix-registered.test \ test-driver-fail.test \ test-harness-vpath-rewrite.test \ test-log.test \ +test-logs-repeated.test \ test-metadata-global-log.test \ test-metadata-global-result.test \ test-metadata-recheck.test \ @@ -1247,6 +1248,21 @@ tap-summary-color.test tap-summary.log tap-summary-color.log: tap-summary-aux.sh EXTRA_DIST += tap-summary-aux.sh +# 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. +check-no-repeated-test-name: + @LC_ALL=C; export LC_ALL; \ + lst='$(TEST_LOGS)'; for log in $$lst; do echo $$log; done \ + | sort | uniq -c | awk '($$1 > 1) { print }' \ + | sed 's/\.log$$//' | grep . >&2 \ + && { \ + echo $@: test names listed above are duplicated >&2; \ + exit 1; \ + }; : +check-local: check-no-repeated-test-name +.PHONY: check-no-repeated-test-name + ## Checking the list of tests. checked_test_extensions = .test .tap expected_list_of_tests = $(handwritten_tests) diff --git a/tests/Makefile.in b/tests/Makefile.in index 8cf3bc41d..0a63b7bb8 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1013,6 +1013,7 @@ test-driver-trs-suffix-registered.test \ test-driver-fail.test \ test-harness-vpath-rewrite.test \ test-log.test \ +test-logs-repeated.test \ test-metadata-global-log.test \ test-metadata-global-result.test \ test-metadata-recheck.test \ @@ -1754,7 +1755,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) check-TESTS + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local check: check-am all-am: Makefile installdirs: @@ -1863,9 +1864,9 @@ uninstall-am: recheck-html .PHONY: all all-am am--redo-logs check check-TESTS check-am check-html \ - clean clean-generic clean-local distclean distclean-generic \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ + check-local clean clean-generic clean-local distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ @@ -1951,6 +1952,21 @@ $(tap_with_common_setup_logs): tap-common-setup.log tap-setup.sh tap-summary.log tap-summary-color.log: tap-summary-aux.sh +# 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. +check-no-repeated-test-name: + @LC_ALL=C; export LC_ALL; \ + lst='$(TEST_LOGS)'; for log in $$lst; do echo $$log; done \ + | sort | uniq -c | awk '($$1 > 1) { print }' \ + | sed 's/\.log$$//' | grep . >&2 \ + && { \ + echo $@: test names listed above are duplicated >&2; \ + exit 1; \ + }; : +check-local: check-no-repeated-test-name +.PHONY: check-no-repeated-test-name + .PHONY: maintainer-check-list-of-tests maintainer-check-list-of-tests: @if diff -u /dev/null /dev/null >/dev/null 2>&1; then \ diff --git a/tests/test-logs-repeated.test b/tests/test-logs-repeated.test new file mode 100644 index 000000000..94dd7c85f --- /dev/null +++ b/tests/test-logs-repeated.test @@ -0,0 +1,45 @@ +#! /bin/sh +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check parallel-tests features: +# - $(TESTS_LOGS) can end up holding duplicated entries +# Such behaviour can be useful for projects that want to verify that +# different test scripts don't end up sharing the same log file. +# (Automake itself is such a project, BTW ;-) + +parallel_tests=yes +. ./defs || Exit 1 + +cat >> configure.in < Makefile.am << 'END' +TEST_EXTENSIONS = .sh .test .bar +TESTS = foo.sh mu.test foo.test foo.bar +.PHONY: verify +verify: + test "`echo $(TEST_LOGS)`" = 'foo.log mu.log foo.log foo.log' +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +./configure +$MAKE verify + +: