I'm pushing these to perl-coverage and merging to master. None of them fix a bug, they merely increase coverage of rare code paths in automake.in (by roughly 0.1%, but hey).
Cheers, Ralf Coverage for corner cases in derive_suffix. Ensure unrelatex SUFFIXES entries and unrelated inference rules are ignored silently. * tests/ext3.test: New test. * tests/Makefile.am: Update. diff --git a/tests/Makefile.am b/tests/Makefile.am index 8107dec..519b406 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -282,6 +282,7 @@ exeext4.test \ exsource.test \ ext.test \ ext2.test \ +ext3.test \ extra.test \ extra3.test \ extra4.test \ diff --git a/tests/ext3.test b/tests/ext3.test new file mode 100755 index 0000000..0a691c5 --- /dev/null +++ b/tests/ext3.test @@ -0,0 +1,41 @@ +#! /bin/sh +# Copyright (C) 2009 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 3 of the License, 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/>. + +# Cover corner cases of derive_suffix wrt. file extensions: +# - extension declared with SUFFIXES but with no suffix rule for it +# - extension with a suffix rule but none that leads us to $(OBJEXT) +# In both cases, we don't try to create a rule; but we shouldn't +# fail either, because magic might be happening behind our back. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = foo bar +foo_SOURCES = foo.goo +SUFFIXES = .goo +bar_SOURCES = bar.woo +.woo.zoo: ; making a zoo $@ from a woo $< +END + +$ACLOCAL +$AUTOMAKE + +Exit 0 Coverage for user-provided _LINK variables. * tests/link_override.test: New test. * tests/Makefile.am: Adjust. diff --git a/tests/Makefile.am b/tests/Makefile.am index 03b04fa..8107dec 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -407,6 +407,7 @@ link_fc.test \ link_fccxx.test \ link_fcxx.test \ link_f_only.test \ +link_override.test \ lisp2.test \ lisp3.test \ lisp4.test \ diff --git a/tests/link_override.test b/tests/link_override.test new file mode 100755 index 0000000..41788a1 --- /dev/null +++ b/tests/link_override.test @@ -0,0 +1,46 @@ +#! /bin/sh +# Copyright (C) 2009 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 3 of the License, 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 to make sure _LINK variables are detected and used as documented. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +END + +cat > Makefile.am << 'END' +bin_PROGRAMS = foo bar baz boo +foo_LINK = $(LINK) +bar_LINK = $(LINK) +bar_LDFLAGS = $(AM_LDFLAGS) +END + +$ACLOCAL +$AUTOMAKE -a + +# We should use foo_LINK not LINK. +grep '.\$(foo_LINK)' Makefile.in +grep '.\$(LINK).*foo' Makefile.in && Exit 1 + +# We should not override the user definition of bar_LINK. +# IOW, bar_LDFLAGS is useless unless bar_LINK refers to it. +grep '^ *bar_LINK *=.*bar_LDFLAGS' Makefile.in && Exit 1 +grep '.\$(bar_LINK).*bar' Makefile.in + +Exit 0 Coverage: warn about substitutions that need EXTRA_PRIMARY. * tests/extra9.test: New test. * tests/Makefile.am: Adjust. diff --git a/tests/Makefile.am b/tests/Makefile.am index 2d01293..03b04fa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -289,6 +289,7 @@ extra5.test \ extra6.test \ extra7.test \ extra8.test \ +extra9.test \ f90only.test \ flavor.test \ flibs.test \ diff --git a/tests/extra9.test b/tests/extra9.test new file mode 100755 index 0000000..fefd385 --- /dev/null +++ b/tests/extra9.test @@ -0,0 +1,46 @@ +#!/bin/sh +# Copyright (C) 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Automake. +# +# GNU Automake 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 3 of the License, or +# (at your option) any later version. +# +# GNU Automake 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 Automake; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# Ensure we warn about substitutions in bin_PROGRAMS if EXTRA_PROGRAMS +# are missing; but only if the former is not AC_SUBSTed itself +# (lib_LIBRARIES is in the same boat here). + +. ./defs || Exit 1 + +set -e + +cat >>configure.in <<'END' +AC_PROG_CC +AC_PROG_RANLIB +AC_SUBST([lib_LIBRARIES]) +AC_SUBST([bins]) +AC_OUTPUT +END + +cat >Makefile.am <<'END' +bin_PROGRAMS = @bins@ +END + +$ACLOCAL +AUTOMAKE_fails +grep 'bin_PROGRAMS.*contains configure substitution' stderr +grep 'lib_LIBRARIES.*contains configure substitution' stderr && Exit 1 + +Exit 0 Coverage: warn about configure substitution in EXTRA_PRIMARY. * tests/subst5.test: New test. * tests/Makefile.am: Update. diff --git a/tests/Makefile.am b/tests/Makefile.am index fe16314..2d01293 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -642,6 +642,7 @@ subst.test \ subst2.test \ subst3.test \ subst4.test \ +subst5.test \ substref.test \ substre2.test \ substtarg.test \ diff --git a/tests/subst5.test b/tests/subst5.test new file mode 100755 index 0000000..7ffa1ad --- /dev/null +++ b/tests/subst5.test @@ -0,0 +1,42 @@ +#! /bin/sh +# Copyright (C) 2009 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 3 of the License, 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/>. + +# Complain about configure substitutions in EXTRA_PRIMARY variables. +# Rationale: we need to know the literal values of, say, PROGRAMS. +# Thus, we allow substitutions in bin_PROGRAMS, but then EXTRA_PROGRAMS +# needs to list possible values of that substitution, literally. + +. ./defs || Exit 1 + +set -e + +cat >>configure.in <<'END' +AC_PROG_CC +AC_SUBST([substed1]) +AC_SUBST([substed2]) +END + +cat > Makefile.am <<'END' +bin_PROGRAMS = @substed1@ +EXTRA_PROGRAMS = @substed2@ +END + +$ACLOCAL +AUTOMAKE_fails +grep 'bin_PROGRAMS.*contains configure substitution' stderr && Exit 1 +grep 'EXTRA_PROGRAMS.*contains configure substitution' stderr + +Exit 0 Coverage for syntax errors with conditionals in included fragments. * tests/condinc2.test: Amend test. diff --git a/tests/condinc2.test b/tests/condinc2.test index 088fb55..69eff59 100755 --- a/tests/condinc2.test +++ b/tests/condinc2.test @@ -1,5 +1,6 @@ #! /bin/sh -# Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 1999, 2001, 2002, 2003, 2009 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 @@ -39,3 +40,23 @@ END $ACLOCAL AUTOMAKE_fails grep 'adjunct:3: too many conditionals closed' stderr + +cat > adjunct << 'END' +if TOBE +target: dependency + rule +END + +AUTOMAKE_fails +grep 'unterminated conditionals' stderr + +cat > adjunct << 'END' +if TOBE +target: dependency + rule +endif +END + +$AUTOMAKE + +Exit 0 Coverage: diagnose variables with forbidden dist_ prefix. * tests/candist.test: New test. * tests/Makefile.am: Update. diff --git a/tests/Makefile.am b/tests/Makefile.am index 6d42996..fe16314 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -95,6 +95,7 @@ badline.test \ badprog.test \ block.test \ bsource.test \ +candist.test \ canon.test \ canon2.test \ canon3.test \ diff --git a/tests/candist.test b/tests/candist.test new file mode 100755 index 0000000..0a859dd --- /dev/null +++ b/tests/candist.test @@ -0,0 +1,34 @@ +#! /bin/sh +# Copyright (C) 2009 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 3 of the License, 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 to make sure things that cannot be dist_'ed are diagnosed. + +. ./defs || Exit 1 + +set -e + +echo AC_OUTPUT >>configure.in + +cat > Makefile.am << 'END' +dist_bin_PROGRAMS = foo +dist_lib_LIBRARIES = libfoo.a +END + +$ACLOCAL +AUTOMAKE_fails +test 2 -eq `grep -c 'dist.*forbidden' stderr` + +Exit 0 Coverage for conditional `else' and `endif' arguments. * tests/cond46.test: New test. * tests/Makefile.am: Update. diff --git a/tests/Makefile.am b/tests/Makefile.am index 98829c9..6d42996 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -187,6 +187,7 @@ cond42.test \ cond43.test \ cond44.test \ cond45.test \ +cond46.test \ condd.test \ condhook.test \ condinc.test \ diff --git a/tests/cond46.test b/tests/cond46.test new file mode 100755 index 0000000..73b6e94 --- /dev/null +++ b/tests/cond46.test @@ -0,0 +1,110 @@ +#! /bin/sh +# Copyright (C) 2009 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 3 of the License, 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/>. + +# Ensure the right condition is listed after `else' and `endif'. + +. ./defs || Exit 1 + +cat >> configure.in << 'END' +AM_CONDITIONAL([USE_A],[test x = y]) +AM_CONDITIONAL([USE_B],[test x = z]) +AC_OUTPUT +END + +$ACLOCAL + +cat > Makefile.am << 'END' +if USE_A +endif !USE_A +END + +AUTOMAKE_fails +grep 'endif.*incompatible with current conditional' stderr + +cat > Makefile.am << 'END' +if USE_A +endif USE_B +END + +AUTOMAKE_fails +grep 'endif.*incompatible with current conditional' stderr + +cat > Makefile.am << 'END' +if USE_A +else +endif USE_A +END + +AUTOMAKE_fails +grep 'endif.*incompatible with current conditional' stderr + +cat > Makefile.am << 'END' +if USE_A +else +endif !USE_A +END + +$AUTOMAKE + +cat > Makefile.am << 'END' +if USE_A +if USE_B +else +endif !USE_A +endif +END + +AUTOMAKE_fails +grep 'endif.*incompatible with current conditional' stderr + +cat > Makefile.am << 'END' +if USE_A +else USE_A +endif +END + +AUTOMAKE_fails +grep 'else.*incompatible with current conditional' stderr + +cat > Makefile.am << 'END' +if USE_A +else USE_B +endif +END + +AUTOMAKE_fails +grep 'else.*incompatible with current conditional' stderr + +cat > Makefile.am << 'END' +if USE_A +if USE_B +else USE_A +endif +endif +END + +AUTOMAKE_fails +grep 'else.*incompatible with current conditional' stderr + +cat > Makefile.am << 'END' +if USE_A +else !USE_A +endif +END + +$AUTOMAKE + +Exit 0