From: Stefano Lattarini Date: Mon, 10 Jan 2011 22:56:43 +0000 (+0100) Subject: tests: add checks on automatically-distributed files X-Git-Tag: v1.11.1b~37^2~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8c0a64515e4ed1e08c8eddb9e5dfd06ce987577;p=thirdparty%2Fautomake.git tests: add checks on automatically-distributed files Related to automake bug#7819. * tests/autodist.test: New test. * tests/autodist-subdir.test: Likewise. * tests/autodist-acconfig.test: Likewise. * tests/autodist-acconfig-no-subdir.test: Likewise. * tests/autodist-aclocal-m4.test: Likewise. * tests/autodist-config-headers.test: Likewise. * tests/autodist-configure-no-subdir.test: Likewise. * tests/autodist-stamp-vti.test: Likewise. * tests/Makefile.am (TESTS): Update. --- diff --git a/ChangeLog b/ChangeLog index b59819f8f..ca2c4810e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-01-10 Stefano Lattarini + + tests: add checks on automatically-distributed files + Related to automake bug#7819. + * tests/autodist.test: New test. + * tests/autodist-subdir.test: Likewise. + * tests/autodist-acconfig.test: Likewise. + * tests/autodist-acconfig-no-subdir.test: Likewise. + * tests/autodist-aclocal-m4.test: Likewise. + * tests/autodist-config-headers.test: Likewise. + * tests/autodist-configure-no-subdir.test: Likewise. + * tests/autodist-stamp-vti.test: Likewise. + * tests/Makefile.am (TESTS): Update. + 2011-01-09 Stefano Lattarini cosmetics: remove trailing whitespaces diff --git a/tests/Makefile.am b/tests/Makefile.am index 8842be389..fe93ac2d3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -94,6 +94,14 @@ ar2.test \ asm.test \ asm2.test \ asm3.test \ +autodist.test \ +autodist-subdir.test \ +autodist-acconfig.test \ +autodist-acconfig-no-subdir.test \ +autodist-aclocal-m4.test \ +autodist-config-headers.test \ +autodist-configure-no-subdir.test \ +autodist-stamp-vti.test \ autohdr.test \ autohdr2.test \ autohdr3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 3bc441555..525425271 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -361,6 +361,14 @@ ar2.test \ asm.test \ asm2.test \ asm3.test \ +autodist.test \ +autodist-subdir.test \ +autodist-acconfig.test \ +autodist-acconfig-no-subdir.test \ +autodist-aclocal-m4.test \ +autodist-config-headers.test \ +autodist-configure-no-subdir.test \ +autodist-stamp-vti.test \ autohdr.test \ autohdr2.test \ autohdr3.test \ diff --git a/tests/autodist-acconfig-no-subdir.test b/tests/autodist-acconfig-no-subdir.test new file mode 100755 index 000000000..e6bd5a98b --- /dev/null +++ b/tests/autodist-acconfig-no-subdir.test @@ -0,0 +1,58 @@ +#! /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 that `acconfig.h' is *not* automatically distributed when +# placed in a subdirectory. +# Related to automake bug#7819. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in < Makefile.am <<'END' +SUBDIRS = sub +sub/acconfig.h: + echo target $@ should not be built >&2; exit 1 +check-local: distdir + ls -l $(distdir)/sub + test ! -f $(distdir)/sub/acconfig.h +END + +mkdir sub + +cat > sub/Makefile.am <<'END' +acconfig.h: + echo target $@ should not be built >&2; exit 1 +check-local: + echo $(DISTFILES) | grep 'acconfig\.h' && exit 1; : + echo $(DIST_COMMON) | grep 'acconfig\.h' && exit 1; : +END + +: > sub/acconfig.h + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +./configure +$MAKE check + +: diff --git a/tests/autodist-acconfig.test b/tests/autodist-acconfig.test new file mode 100755 index 000000000..49ab2f052 --- /dev/null +++ b/tests/autodist-acconfig.test @@ -0,0 +1,46 @@ +#! /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 that `acconfig.h' is automatically distributed if it exists +# (at automake runtime). +# Related to automake bug#7819. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in < Makefile.am <<'END' +.PHONY: test +test: distdir + ls -l $(distdir) + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]acconfig\.h ' + test -f $(distdir)/acconfig.h +END + +: > acconfig.h + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +./configure +$MAKE test + +: diff --git a/tests/autodist-aclocal-m4.test b/tests/autodist-aclocal-m4.test new file mode 100755 index 000000000..3f53d59c4 --- /dev/null +++ b/tests/autodist-aclocal-m4.test @@ -0,0 +1,55 @@ +#! /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 that `aclocal.m4' is not automatically distributed if not +# required to build `configure'. This is *really* a corner-case +# check, and the behaviour it checks is not documented either, so +# if that behaviour is deliberately changed in the future, just +# remove this test. +# Related to automake bug#7819. + +. ./defs || Exit 1 + +set -e + +{ echo 'm4_include([defs.m4])' + cat configure.in + echo 'AC_OUTPUT' +} > t +mv -f t configure.in + +cat > Makefile.am <<'END' +.PHONY: test +test: distdir + ls -l $(distdir) + test ! -f $(distdir)/aclocal.m4 + echo $(DISTFILES) | grep 'aclocal\.m4' && exit 1; : + echo $(DIST_COMMON) | grep 'aclocal\.m4' && exit 1; : +check-local: test +END + +: > defs.m4 +$ACLOCAL +mv -f aclocal.m4 defs.m4 + +$AUTOMAKE +$AUTOCONF + +./configure +$MAKE test +$MAKE distcheck + +: diff --git a/tests/autodist-config-headers.test b/tests/autodist-config-headers.test new file mode 100755 index 000000000..66c9beadc --- /dev/null +++ b/tests/autodist-config-headers.test @@ -0,0 +1,61 @@ +#! /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 that config.h.bot and config.h.top are automatically +# distributed if the AC_CONFIG_HADERS macro is used and they +# exist at automake runtime. +# Related to automake bug#7819. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in < Makefile.am <<'END' +.PHONY: test +test: distdir + ls -l $(distdir) $(distdir)/sub + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]config\.h\.bot ' + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]config\.h\.top ' + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]cfg2\.h\.bot ' + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]cfg2\.h\.top ' + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]sub/config\.h\.bot ' + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]sub/config\.h\.top ' + test -f $(distdir)/config.h.bot + test -f $(distdir)/config.h.top + test -f $(distdir)/cfg2.h.bot + test -f $(distdir)/cfg2.h.top + test -f $(distdir)/sub/config.h.bot + test -f $(distdir)/sub/config.h.top +END + +mkdir sub +touch config.h.in config.h.top config.h.bot \ + conf2.hin cfg2.h.top cfg2.h.bot \ + sub/config.h.in sub/config.h.top sub/config.h.bot + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +./configure +$MAKE test + +: diff --git a/tests/autodist-configure-no-subdir.test b/tests/autodist-configure-no-subdir.test new file mode 100755 index 000000000..db640c495 --- /dev/null +++ b/tests/autodist-configure-no-subdir.test @@ -0,0 +1,72 @@ +#! /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 that `configure', `configure.ac' and `configure.in' are *not* +# automatically distributed when placed in a subdirectory. +# Related to automake bug#7819. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in < Makefile.am <<'END' +SUBDIRS = sub +dontbuild = echo target $@ should not be built >&2; exit 1 +sub/configure: + $(dontbuild) +sub/configure.ac: + $(dontbuild) +sub/configure.in: + $(dontbuild) +check-local: distdir + ls -l $(distdir)/sub + test ! -f $(distdir)/sub/configure + test ! -f $(distdir)/sub/configure.in + test ! -f $(distdir)/sub/configure.ac +END + +mkdir sub + +cat > sub/Makefile.am <<'END' +dontbuild = echo target $@ should not be built >&2; exit 1 +configure: + $(dontbuild) +configure.ac: + $(dontbuild) +configure.in: + $(dontbuild) +check-local: + echo $(DISTFILES) | grep 'configure' && exit 1; : + echo $(DIST_COMMON) | grep 'configure' && exit 1; : +END + +: > sub/configure.ac +: > sub/configure.in +: > sub/configure + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +./configure +$MAKE check + +: diff --git a/tests/autodist-stamp-vti.test b/tests/autodist-stamp-vti.test new file mode 100755 index 000000000..4f37e1417 --- /dev/null +++ b/tests/autodist-stamp-vti.test @@ -0,0 +1,60 @@ +#! /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 that `stamp-vti' is automatically distributed when info_TEXINFOS +# and version.texi are involved. +# Related to automake bug#7819. + +required=makeinfo +. ./defs || Exit 1 + +set -e + +cat >> configure.in << END +AC_OUTPUT +END + +cat > Makefile.am << 'END' +info_TEXINFOS = foo.texi +.PHONY: test +test: all distdir + ls -l $(distdir) + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]stamp-vti ' + test -f $(distdir)/stamp-vti +END + +cat > foo.texi << 'END' +\input texinfo +@setfilename foo.info +@settitle Zardoz +@node Top +@include version.texi +bar baz quux +@bye +END + +# Required when using Texinfo. +: > texinfo.tex +cp "$testsrcdir/../lib/mdate-sh" . + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +./configure +$MAKE test + +: diff --git a/tests/autodist-subdir.test b/tests/autodist-subdir.test new file mode 100755 index 000000000..db694f876 --- /dev/null +++ b/tests/autodist-subdir.test @@ -0,0 +1,147 @@ +#! /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 that automake really automatically distributes all the files +# it advertises to do, even when in subdirectories. +# +# This behavior might be suboptimal, but it has been in place for quite +# a long time, and it would be risky to change it now. See also the +# discussion of automake bug#7819: +# +# +# Keep this test in sync with sister test `autodist.test'. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_CONFIG_FILES([sub/Makefile]) +AC_OUTPUT +END + +$ACLOCAL +$AUTOCONF + +# The automake manual states that the list of automatically-distributed +# files should be given by `automake --help'. +list=`$AUTOMAKE --help \ + | sed -n '/^Files .*automatically distributed.*if found/,/^ *$/p' \ + | sed 1d` +list=`for f in $list; do + case $f in + configure|configure.in|configure.ac) + # See test 'autodist-configure-no-subdir.test'. + ;; + aclocal.m4) + # This file should be distributed only when it is a real + # dependency for configure. Anyway, not a check to be + # performed in this test. + ;; + acconfig.h) + # Works only when it really exists, not when it is a + # target in Makefile.am. + ;; + stamp-vti) + # Works only when using info_TEXINFOS and version.texi. + ;; + config.h.bot|config.h.top) + # Works only when the AC_CONFIG_HADERS macro is used. + ;; + *) + echo $f + ;; + esac + done` +# Normalize whitespace, just in case. +list=`echo $list` + +test -n "$list" + +cat > Makefile.am <<'END' +SUBDIRS = sub +check-local: +## For debugging. + @echo DIST_COMMON: + @for f in $(DIST_COMMON); do echo " $$f"; done + @echo DISTDIR: + @ls -l $(distdir) | sed 's/^/ /' +## Now the checks. + @for f in $(autodist_list); do \ + echo "file: sub/$$f"; \ + test -f $(distdir)/sub/$$f \ + || { echo $$f: distdir fail >&2; exit 1; }; \ + done +END + +mkdir sub + +cat > sub/Makefile.am <<'END' +include distfiles.am +check-local: +## For debugging. + @echo DIST_COMMON: + @for f in $(DIST_COMMON); do echo " $$f"; done + @echo DISTDIR: + @ls -l $(distdir) | sed 's/^/ /' +## Now the checks. + @for f in $(autodist_list); do \ + echo "file: $$f"; \ + ## Some filenames might contain dots, but this won't cause spurious + ## failures, and "spurious successes" are so unlikely that they're + ## not worth worrying about. + echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \ + || { echo $$f: distcom fail >&2; exit 1; }; \ + done +END + +: First try listing the automatically-distributed files in proper +: targets in Makefile.am + +echo "MAINTAINERCLEANFILES = $list" > sub/distfiles.am +for f in $list; do echo "$f :; touch $f"; done >> sub/distfiles.am + +cat sub/distfiles.am # For debugging. + +$AUTOMAKE -a + +./configure + +$MAKE distdir +autodist_list="$list" $MAKE check + +$MAKE maintainer-clean +test ! -f sub/README # Sanity check. +rm -rf $me-1.0 # Remove $(distdir). + +: Now try creating the automatically-distributed files before +: running automake. + +: > sub/distfiles.am +for f in $list; do + echo dummy > sub/$f +done + +ls -l # For debugging. + +$AUTOMAKE + +./configure + +$MAKE distdir +autodist_list="$list" $MAKE check + +: diff --git a/tests/autodist.test b/tests/autodist.test new file mode 100755 index 000000000..34b95266a --- /dev/null +++ b/tests/autodist.test @@ -0,0 +1,136 @@ +#! /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 that automake really automatically distributes all the files +# it advertises to do. +# Related to automake bug#7819. +# Keep this test in sync with sister test `autodist-subdir.test'. + +. ./defs || Exit 1 + +set -e + +# Ensure we are run from the right directory. +# (The last thing we want is to delete some random user files.) +test -f ../defs-static +rm -f * + +cat > configure.in < Makefile.am <<'END' +include distfiles.am +check-local: +## For debugging. + @echo DIST_COMMON: + @for f in $(DIST_COMMON); do echo " $$f"; done + @echo DISTDIR: + @ls -l $(distdir) | sed 's/^/ /' +## Now the checks. + @for f in $(autodist_list); do \ + echo "file: $$f"; \ + test -f $(distdir)/$$f \ + || { echo $$f: distdir fail >&2; exit 1; }; \ + ## Some filenames might contain dots, but this won't cause spurious + ## failures, and "spurious successes" are so unlikely that they're + ## not worth worrying about. + echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \ + || { echo $$f: distcom fail >&2; exit 1; }; \ + done +END + +: First try listing the automatically-distributed files in proper +: targets in Makefile.am + +echo "MAINTAINERCLEANFILES = $list" > distfiles.am +for f in $list; do echo "$f :; touch $f"; done >> distfiles.am + +cat distfiles.am # For debugging. + +$AUTOMAKE -a + +./configure + +$MAKE distdir +autodist_list="$list" $MAKE check + +$MAKE maintainer-clean +test ! -f README # Sanity check. +rm -rf $me-1.0 # Remove $(distdir). + +: Now try creating the automatically-distributed files before +: running automake. + +: > distfiles.am +for f in $list; do + echo dummy > $f +done + +ls -l # For debugging. + +$AUTOMAKE + +./configure + +$MAKE distdir +autodist_list="$list" $MAKE check + +: