* tests/subst2.test: Test removed, split into ... * tests/programs-primary-rewritten.test: ... this test ... * tests/subst-no-trailing-empty-line.test: ... and this one ... * tests/extra-programs-empty.test: ... and this one. * tests/Makefile.am (TESTS): Update. --- ChangeLog | 9 ++ tests/Makefile.am | 4 +- tests/Makefile.in | 4 +- tests/{subst2.test => extra-programs-empty.test} | 44 +++++----- ...subst2.test => programs-primary-rewritten.test} | 50 +++++++----- tests/subst-no-trailing-empty-line.test | 89 ++++++++++++++++++++ 6 files changed, 155 insertions(+), 45 deletions(-) copy tests/{subst2.test => extra-programs-empty.test} (52%) rename tests/{subst2.test => programs-primary-rewritten.test} (55%) create mode 100755 tests/subst-no-trailing-empty-line.test
diff --git a/ChangeLog b/ChangeLog index 62c6ca4..24183b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-05-26 Stefano Lattarini <stefano.lattar...@gmail.com> + tests: split 'subst2.test' to improve modularity and coverage + * tests/subst2.test: Test removed, split into ... + * tests/programs-primary-rewritten.test: ... this test ... + * tests/subst-no-trailing-empty-line.test: ... and this one ... + * tests/extra-programs-empty.test: ... and this one. + * tests/Makefile.am (TESTS): Update. + +2011-05-26 Stefano Lattarini <stefano.lattar...@gmail.com> + tests: tweak and improve tests on Automake conditionals The "avoid the requirement of a working compiler" we refer about below is obtained by disabling automatic dependency tracking and diff --git a/tests/Makefile.am b/tests/Makefile.am index bcb65d8..09adc65 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -461,6 +461,7 @@ extra9.test \ extra10.test \ extra11.test \ extra12.test \ +extra-programs-empty.test \ extradep.test \ extradep2.test \ f90only.test \ @@ -792,6 +793,7 @@ primary.test \ primary2.test \ primary3.test \ proginst.test \ +programs-primary-rewritten.test \ python.test \ python2.test \ python3.test \ @@ -939,10 +941,10 @@ subpkg2.test \ subpkg3.test \ subpkg4.test \ subst.test \ -subst2.test \ subst3.test \ subst4.test \ subst5.test \ +subst-no-trailing-empty-line.test \ substref.test \ substre2.test \ substtarg.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 107b359..ad8b2c0 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -726,6 +726,7 @@ extra9.test \ extra10.test \ extra11.test \ extra12.test \ +extra-programs-empty.test \ extradep.test \ extradep2.test \ f90only.test \ @@ -1057,6 +1058,7 @@ primary.test \ primary2.test \ primary3.test \ proginst.test \ +programs-primary-rewritten.test \ python.test \ python2.test \ python3.test \ @@ -1204,10 +1206,10 @@ subpkg2.test \ subpkg3.test \ subpkg4.test \ subst.test \ -subst2.test \ subst3.test \ subst4.test \ subst5.test \ +subst-no-trailing-empty-line.test \ substref.test \ substre2.test \ substtarg.test \ diff --git a/tests/subst2.test b/tests/extra-programs-empty.test similarity index 52% copy from tests/subst2.test copy to tests/extra-programs-empty.test index d64d8c0..992c5ee 100755 --- a/tests/subst2.test +++ b/tests/extra-programs-empty.test @@ -14,40 +14,40 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Make sure a multi-line definition cannot be terminated by an empty -# line (when there are @substitutions@ inside). +# Test that EXTRA_PROGRAMS doesn't get removed because it is empty. +# This check hs been introduced in commit `Release-1-9-254-g9d0eaef' +# into the former test `subst2.test'. -required=cc . ./defs || Exit 1 cat >> configure.in << 'END' +AC_CONFIG_FILES([Makefile2 Makefile3]) +AC_SUBST([prog]) AC_PROG_CC -AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWX]) -AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWXY]) -AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWXYZ]) AC_OUTPUT END -cat >Makefile.am <<'END' -bin_PROGRAMS = x @ABCDEFGHIJKLMNOPQRSTUVWX@ @ABCDEFGHIJKLMNOPQRSTUVWXY@ @ABCDEFGHIJKLMNOPQRSTUVWXYZ@ +cat > Makefile.am <<'END' EXTRA_PROGRAMS = +END -EXEEXT = .bin +cat > Makefile2.am <<'END' +bin_PROGRAMS = a @prog@ b +EXTRA_PROGRAMS = +END -print-programs: - @echo BEG: $(bin_PROGRAMS) :END +cat > Makefile3.am <<'END' +empty = +EXTRA_PROGRAMS = $(empty) END $ACLOCAL -$AUTOCONF $AUTOMAKE -./configure -EXEEXT=.bin $MAKE print-programs >foo -cat foo -grep 'BEG: x.bin :END' foo -EXEEXT=.bin am__empty=X $MAKE -e print-programs >foo -cat foo -grep 'BEG: x.bin X :END' foo - -# Test for another bug, where EXTRA_PROGRAMS was removed because it was empty. -grep EXTRA_PROGRAMS Makefile.in + +grep '^EXTRA_PROGRAMS = *$' Makefile.in +grep '^EXTRA_PROGRAMS = *$' Makefile2.in +# Be laxer here, since EXTRA_PROGRAMS might be internally rewritten +# by Automake when it contains references to other variables. +grep '^EXTRA_PROGRAMS =' Makefile3.in + +: diff --git a/tests/subst2.test b/tests/programs-primary-rewritten.test similarity index 55% rename from tests/subst2.test rename to tests/programs-primary-rewritten.test index d64d8c0..e52bd56 100755 --- a/tests/subst2.test +++ b/tests/programs-primary-rewritten.test @@ -14,40 +14,48 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Make sure a multi-line definition cannot be terminated by an empty -# line (when there are @substitutions@ inside). +# Make sure xxx_PROGRAMS gets properly rewritten where needed. These +# checks have been introduced in commit `Release-1-9-254-g9d0eaef' into +# the former test `subst2.test'. -required=cc . ./defs || Exit 1 cat >> configure.in << 'END' -AC_PROG_CC -AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWX]) -AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWXY]) -AC_SUBST([ABCDEFGHIJKLMNOPQRSTUVWXYZ]) +AC_SUBST([FOO], [c]) AC_OUTPUT END cat >Makefile.am <<'END' -bin_PROGRAMS = x @ABCDEFGHIJKLMNOPQRSTUVWX@ @ABCDEFGHIJKLMNOPQRSTUVWXY@ @ABCDEFGHIJKLMNOPQRSTUVWXYZ@ +AUTOMAKE_OPTIONS = no-dependencies +CC = false +EXEEXT = .bin + +check_PROGRAMS = a +bin_PROGRAMS = b @FOO@ +noinst_PROGRAMS = $(bar) $(baz:=de) EXTRA_PROGRAMS = -EXEEXT = .bin +bar = zardoz +baz = mau -print-programs: - @echo BEG: $(bin_PROGRAMS) :END +.PHONY: test +test: + test '$(check_PROGRAMS)' = a.bin + test '$(bin_PROGRAMS)' = 'b.bin c' + test '$(noinst_PROGRAMS)' = 'zardoz.bin maude.bin' END $ACLOCAL -$AUTOCONF $AUTOMAKE + +grep PROGRAMS Makefile.in # For debugging. + +# Check that no useless indirections are used. +grep '^check_PROGRAMS = a$(EXEEXT)$' Makefile.in +grep '^bin_PROGRAMS = b$(EXEEXT) @FOO@$' Makefile.in + +$AUTOCONF ./configure -EXEEXT=.bin $MAKE print-programs >foo -cat foo -grep 'BEG: x.bin :END' foo -EXEEXT=.bin am__empty=X $MAKE -e print-programs >foo -cat foo -grep 'BEG: x.bin X :END' foo - -# Test for another bug, where EXTRA_PROGRAMS was removed because it was empty. -grep EXTRA_PROGRAMS Makefile.in +$MAKE test + +: diff --git a/tests/subst-no-trailing-empty-line.test b/tests/subst-no-trailing-empty-line.test new file mode 100755 index 0000000..595644e --- /dev/null +++ b/tests/subst-no-trailing-empty-line.test @@ -0,0 +1,89 @@ +#! /bin/sh +# Copyright (C) 2003, 2006, 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/>. + +# If the last line of a automake-rewritten definition is made only of +# @substitutions@, automake should take care of appending an empty +# variable to make sure that line cannot end up substituted as a blank +# line (that would confuse HP-UX Make). +# These checks have been introduced in commit `Release-1-9-254-g9d0eaef' +# into the former test `subst2.test'. + +. ./defs || Exit 1 + +v1=ABCDEFGHIJKLMNOPQRSTUVWX +v2=ABCDEFGHIJKLMNOPQRSTUVWXY +v3=ABCDEFGHIJKLMNOPQRSTUVWXYZ +bs='\\' # Literal backslash for grep. + +cat >> configure.in <<END +AC_SUBST([A], ['']) +# These are deliberately quite long, so that the xxx_PROGRAMS definition +# in Makefile.am below will be split on multiple lines, with the last +# line +AC_SUBST([$v1], ['']) +AC_SUBST([$v2], ['']) +AC_SUBST([$v3], ['']) +AC_OUTPUT +END + +cat >Makefile.am <<END +AUTOMAKE_OPTIONS = no-dependencies +CC = false +EXEEXT = + +noinst_PROGRAMS = x @$v1@ @$v2@ @$v3@ +bin_PROGRAMS = @A@ mu @$v2@ @$v3@ +check_PROGRAMS = zardoz \$(noinst_PROGRAMS) + +## Required whenever there are @substituted@ values in the +## PROGRAMS primary, otherwise automake will complain. +EXTRA_PROGRAMS = + +print-programs: + @echo BEG1: \$(noinst_PROGRAMS) :END1 + @echo BEG2: \$(bin_PROGRAMS) :END2 + @echo BEG3: \$(check_PROGRAMS) :END3 +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +$EGREP -n 'ABCD|am__empty' Makefile.in # For debugging, +# Sanity check. +test `$EGREP -c "^[ $tab]*@$v2@ @$v3@[ $tab]*$bs?$" Makefile.in` -eq 2 + +./configure +{ + sed -n '/^noinst_PROGRAMS =/,/[^\\]$/p' Makefile + sed -n '/^bin_PROGRAMS =/,/[^\\]$/p' Makefile + sed -n '/^check_PROGRAMS =/,/[^\\]$/p' Makefile +} >t-programs +cat t-programs +grep '^ *$' t-programs && Exit 1 + +$MAKE print-programs >stdout || { cat stdout; Exit 1; } +cat stdout +grep '^BEG1: x :END1$' stdout +grep '^BEG2: mu :END2$' stdout +grep '^BEG3: zardoz x :END3$' stdout + +am__empty=X $MAKE -e print-programs >stdout || { cat stdout; Exit 1; } +cat stdout +grep '^BEG1: x X :END1$' stdout +grep '^BEG2: mu X :END2$' stdout +grep '^BEG3: zardoz x X :END3$' stdout + +: -- 1.7.2.3