summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/Makefile.in6
-rw-r--r--tests/distcheck-hook-m4.am30
-rwxr-xr-xtests/distcheck-missing-m4.test102
-rwxr-xr-xtests/distcheck-outdated-m4.test88
6 files changed, 243 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0152bfc8c..14b8929dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-09-09 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ coverage: distcheck-hook to catch missing/outdated *.m4 files
+ Related to automake bug#9037.
+ * tests/distcheck-missing-m4.test: New test.
+ * tests/distcheck-outdated-m4.test: Likewise.
+ * tests/distcheck-hook-m4.am: New data file, used by the new
+ tests.
+ * tests/Makefile.am (distcheck-m4-missing.log,
+ distcheck-m4-outdated.log): Depend on it.
+ (EXTRA_DIST): Distribute it.
+ (TESTS): Add the new tests.
+
2011-09-06 Stefano Lattarini <stefano.lattarini@gmail.com>
aclocal: more granularity in acdir overriding
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1814e43e6..fe89caaf5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -410,6 +410,8 @@ distcheck-configure-flags-am.test \
distcheck-configure-flags-subpkg.test \
distcheck-hook.test \
distcheck-hook2.test \
+distcheck-missing-m4.test \
+distcheck-outdated-m4.test \
dmalloc.test \
doc-parsing-buglets-colneq-subst.test \
doc-parsing-buglets-tabs.test \
@@ -1073,10 +1075,12 @@ $(parallel_tests)
EXTRA_DIST += $(TESTS)
-
# Dependencies valid for each test case.
$(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
+distcheck-missing-m4.log distcheck-outdated-m4.log: distcheck-hook-m4.am
+EXTRA_DIST += distcheck-hook-m4.am
+
clean-local: clean-local-check
.PHONY: clean-local-check
clean-local-check:
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 98bdb5ab5..da0702a8d 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -295,7 +295,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
MAINTAINERCLEANFILES = $(parallel_tests) $(instspc_tests)
EXTRA_DIST = ChangeLog-old gen-parallel-tests instspc-tests.sh \
- $(TESTS)
+ $(TESTS) distcheck-hook-m4.am
XFAIL_TESTS = all.test auxdir2.test cond17.test gcj6.test \
override-conditional-2.test pr8365-remake-timing.test \
yacc-dist-nobuild-subdir.test vala-vpath.test txinfo5.test \
@@ -682,6 +682,8 @@ distcheck-configure-flags-am.test \
distcheck-configure-flags-subpkg.test \
distcheck-hook.test \
distcheck-hook2.test \
+distcheck-missing-m4.test \
+distcheck-outdated-m4.test \
dmalloc.test \
doc-parsing-buglets-colneq-subst.test \
doc-parsing-buglets-tabs.test \
@@ -1752,6 +1754,8 @@ $(instspc_tests:.test=.log): instspc-tests.sh instspc-data.log
# Dependencies valid for each test case.
$(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
+distcheck-missing-m4.log distcheck-outdated-m4.log: distcheck-hook-m4.am
+
clean-local: clean-local-check
.PHONY: clean-local-check
clean-local-check:
diff --git a/tests/distcheck-hook-m4.am b/tests/distcheck-hook-m4.am
new file mode 100644
index 000000000..88681e983
--- /dev/null
+++ b/tests/distcheck-hook-m4.am
@@ -0,0 +1,30 @@
+## Data files for some tests. Not used in the automake build system.
+##
+## 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/>.
+
+distcheck-hook:
+ @fatal () { echo "$@: $$*" >&2; exit 1; }; \
+ $(am__cd) $(distdir) && chmod u+w . && mkdir _m4 \
+ || fatal "cannot setup distdir"; \
+ $(ACLOCAL) -I _m4 $(ACLOCAL_AMFLAGS) --install --output=_am.m4 \
+ || fatal "cannot regenerate aclocal.m4"; \
+ lst=`ls _m4 | tr '\012\015' ' '`; \
+ if test -n "$$lst"; then \
+ fatal "required m4 files not distributed or outdated: $$lst"; \
+ fi; \
+ $(AUTOCONF) -o /dev/null || fatal "can't remake configure"; \
+ rm -rf _m4 _am.m4 autom4te.cache && chmod a-w . \
+ || fatal "cannot reset distdir"
diff --git a/tests/distcheck-missing-m4.test b/tests/distcheck-missing-m4.test
new file mode 100755
index 000000000..f4e0edad6
--- /dev/null
+++ b/tests/distcheck-missing-m4.test
@@ -0,0 +1,102 @@
+#! /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/>.
+
+# Test that we can define a distcheck-hook to diagnose m4 files
+# missing from the dist tarball (interaction with `--install').
+# See automake bug#9037.
+
+. ./defs || Exit 1
+
+set -e
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+
+cp "$testsrcdir"/distcheck-hook-m4.am . \
+ || fatal_ "cannot fetch makefile fragment \`distcheck-hook-m4.am'"
+
+cat > Makefile.am << 'END'
+## The lack of `--install' here is meant.
+ACLOCAL_AMFLAGS = -I m4
+include $(srcdir)/distcheck-hook-m4.am
+END
+
+cat >> configure.in << 'END'
+dnl We *deliberately* don't use m4_pattern_forbid here.
+AC_OUTPUT
+MY_FOO
+MY_BAR
+MY_BAZ
+END
+
+mkdir m4 acdir acdir1 acdir2
+
+cat > acdir/dirlist << END
+$cwd/acdir1
+$cwd/acdir2
+END
+
+echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
+echo 'AC_DEFUN([MY_BAR], [:])' > acdir1/bar.m4
+echo 'AC_DEFUN([MY_BAZ], [:])' > acdir1/baz.m4
+echo 'AC_DEFUN([MY_QUX], [:])' > acdir2/qux.m4
+
+ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
+
+# We don't use `--install' here. Our distcheck-hook should catch this.
+$ACLOCAL -I m4
+$AUTOCONF
+$EGREP 'MY_(FOO|BAR|BAZ)' configure && Exit 1 # Sanity check.
+$AUTOMAKE
+
+./configure
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+$EGREP "required m4 file.*not distributed.* bar.m4( |$)" output
+$EGREP "required m4 file.*not distributed.* baz.m4( |$)" output
+# Check that we don't fail for spurious errors.
+$EGREP -i 'mkdir:|autom4te.*\.cache|:.*(permission|denied)' output && Exit 1
+
+# Now we use `--install', and "make distcheck" should pass.
+$ACLOCAL -I m4 --install
+test -f m4/bar.m4 # Sanity check.
+test -f m4/baz.m4 # Likewise.
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+# We start to use a new "third-party" macro from a new .m4 file, but forget
+# to re-run "aclocal --install" by hand, relying on automatic remake rules.
+# Our distcheck-hook should catch this too.
+echo MY_QUX >> configure.in
+
+$MAKE
+$EGREP 'MY_(FOO|BAR|BAZ|QUX)' configure && Exit 1 # Sanity check.
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+$EGREP "required m4 file.*not distributed.* qux.m4( |$)" output
+# Check that we don't fail for spurious errors.
+$EGREP -i 'mkdir:|autom4te.*\.cache|permission|denied' output && Exit 1
+# Check that we don't complain for files that should have been found.
+grep " ba[rz].m4" output && Exit 1
+
+# Now we again use `--install', and "make distcheck" should pass.
+$ACLOCAL -I m4 --install
+test -f m4/qux.m4 # Sanity check.
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+:
diff --git a/tests/distcheck-outdated-m4.test b/tests/distcheck-outdated-m4.test
new file mode 100755
index 000000000..74f2922a5
--- /dev/null
+++ b/tests/distcheck-outdated-m4.test
@@ -0,0 +1,88 @@
+#! /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/>.
+
+# Test that we can define a distcheck-hook to diagnose outdated m4
+# files in a dist tarball (interaction with `--install').
+# See automake bug#9037.
+
+. ./defs || Exit 1
+
+set -e
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+
+cp "$testsrcdir"/distcheck-hook-m4.am . \
+ || fatal_ "cannot fetch makefile fragment \`distcheck-hook-m4.am'"
+
+cat > Makefile.am << 'END'
+## The lack of `--install' here is meant.
+ACLOCAL_AMFLAGS = -I m4
+include $(srcdir)/distcheck-hook-m4.am
+END
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+MY_FOO
+MY_BAR
+MY_BAZ
+END
+
+mkdir m4 acdir
+echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
+echo 'AC_DEFUN([MY_BAR], [:])' > acdir/bar.m4
+cat > acdir/baz.m4 << 'END'
+# serial 1
+AC_DEFUN([MY_BAZ], [:])
+END
+
+ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
+
+# We don't use `--install' here. Our distcheck-hook should catch this.
+$ACLOCAL -I m4 --install
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distcheck # Sanity check.
+
+# We start to use a new "third-party" macro in a new version
+# of a pre-existing third-party m4 file, but forget to re-run
+# "aclocal --install" by hand, relying on automatic remake
+# rules. Our distcheck-hook should catch this too.
+echo MY_ZARDOZ >> configure.in
+
+cat > acdir/baz.m4 << 'END'
+# serial 2
+AC_DEFUN([MY_BAZ], [:])
+AC_DEFUN([MY_ZARDOZ], [:])
+END
+
+$MAKE # Rebuild configure and makefiles.
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+
+$EGREP "required m4 file.* outdated.* baz.m4( |$)" output
+# Check that we don't fail for spurious errors.
+$EGREP -i 'mkdir:|autom4te.*\.cache|permission|denied' output && Exit 1
+# Check that we don't complain for files that should have been found.
+$EGREP " (foo|bar).m4" output && Exit 1
+
+# Now we again use `--install', and "make distcheck" should pass.
+$ACLOCAL -I m4 --install
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+: