recheck: fix interaction with "make -n"
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 13 Jan 2012 21:39:47 +0000 (22:39 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 16 Jan 2012 17:33:35 +0000 (18:33 +0100)
* lib/am/check.am (recheck): Ensure the recipe does not erroneously
remove '.log' files when running under "make -n".  For the sake of
NetBSD make, this also means that ...
(.MAKE): ... this cannot depend on 'recheck' anymore.
* tests/parallel-tests-dryrun.test: New test.
* tests/list-of-tests.mk: Add it.

lib/am/check.am
tests/list-of-tests.mk
tests/parallel-tests-dryrun.test [new file with mode: 0755]

index 47561ae..e0a453b 100644 (file)
@@ -272,8 +272,12 @@ check-TESTS recheck:
        done; \
 ## Under "make recheck", remove the logs of the files to recheck, so that
 ## those will be rerun by the "make test-suite.log" recursive invocation
-## below.
-       test $@ != recheck || test -z "$$list" || rm -f $$list || exit 1; \
+## below.  But use a proper hack to avoid extra files removal when running
+## under "make -n".
+       if test $@ = recheck && test -n "$$list"; then \
+         echo "am--clean: ; rm -f $$list" \
+           | $(MAKE) $(AM_MAKEFLAGS) -f - am--clean || exit 1; \
+       fi; \
        $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$list"
 
 ## Recheck must depend on $(check_SCRIPTS), $(check_PROGRAMS), etc.
@@ -282,7 +286,6 @@ recheck: %CHECK_DEPS%
 AM_RECURSIVE_TARGETS += check recheck
 
 .PHONY: recheck
-.MAKE: recheck
 
 ## ----------------------------------------------- ##
 ## Produce HTML.  To be removed in automake 1.12.  ##
index 9d95e18..e88ad1a 100644 (file)
@@ -617,6 +617,7 @@ parallel-tests7.test \
 parallel-tests8.test \
 parallel-tests9.test \
 parallel-tests10.test \
+parallel-tests-dryrun.test \
 parallel-tests-harderror.test \
 parallel-tests-unreadable-log.test \
 parallel-tests-subdir.test \
diff --git a/tests/parallel-tests-dryrun.test b/tests/parallel-tests-dryrun.test
new file mode 100755 (executable)
index 0000000..c79a293
--- /dev/null
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2012 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 interactions with "make -n".
+
+parallel_tests=yes
+. ./defs || Exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am <<'END'
+TESTS = foo.test bar.test
+$(TESTS):
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# Avoid confusion with test logs.
+rm -f config.log
+
+log_files='test-suite.log foo.log bar.log'
+html_files='test-suite.html foo.html bar.html'
+the_files="$log_files $html_files"
+
+all_exist ()
+{
+  st=0
+  for i in $*; do
+    test -f $i || { echo File $i not found; st=1; }
+  done
+  test $st -eq 0
+}
+
+none_exist ()
+{
+  st=0
+  for i in $*; do
+    { test -r $i || test -f $i; } && { echo File $i found; st=1; }
+  done
+  test $st -eq 0
+}
+
+for targ in check recheck check-html recheck-html $the_files; do
+  $MAKE -n "$targ"
+  none_exist $the_files
+done
+
+touch $the_files
+
+$MAKE -n mostlyclean
+all_exist $the_files
+$MAKE -n clean
+all_exist $the_files
+
+cat > foo.test <<'END'
+#! /bin/sh
+exit 0
+END
+
+cat > bar.test <<'END'
+#! /bin/sh
+exit 1
+END
+
+chmod a+x foo.test bar.test
+
+$MAKE check && Exit 1
+
+for targ in recheck recheck-html clean mostlyclean distclean; do
+  $MAKE -n "$targ"
+  all_exist $the_files
+done
+
+: