]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
testsuite: different test scripts cannot share the same basename
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 28 Aug 2011 09:48:44 +0000 (11:48 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 28 Aug 2011 09:49:35 +0000 (11:49 +0200)
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.

ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/test-logs-repeated.test [new file with mode: 0644]

index af6d0d4d78f612e3bcf3f95055f9cd02b96fb236..8e4e6d74424f4e15b7ca8b79fb0616b191ec2c69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-08-28  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       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  <stefano.lattarini@gmail.com>
 
        tests: fix spurious failure for awk implementation of TAP driver
index aee597818ebdb5d665c4447df831b5be314d3e1f..95d9efa2987a6de0626fcab1b78ecef6585ff594 100644 (file)
@@ -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)
index 8cf3bc41d671ac8ad897566c0be1a4b8e7a33974..0a63b7bb80ec89fa1f8ba88e79434d738b5107e2 100644 (file)
@@ -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 (file)
index 0000000..94dd7c8
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+# 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 <<END
+AC_OUTPUT
+END
+
+cat > 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
+
+: