]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: split 'subst2.test' to improve modularity and coverage
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 26 May 2011 20:28:45 +0000 (22:28 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 26 May 2011 20:41:59 +0000 (22:41 +0200)
* 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
tests/Makefile.am
tests/Makefile.in
tests/extra-programs-empty.test [new file with mode: 0755]
tests/programs-primary-rewritten.test [moved from tests/subst2.test with 55% similarity]
tests/subst-no-trailing-empty-line.test [new file with mode: 0755]

index 62c6ca47d62cc17abb274450a6cd6e34c2af033e..24183b73daacc7b8c21ac1f9f281e450c984d6c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-05-26  Stefano Lattarini  <stefano.lattarini@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.lattarini@gmail.com>
 
        tests: tweak and improve tests on Automake conditionals
index bcb65d8db121c38c2c70d3f84abaf584112491c8..09adc65178adeffcc70c20b7649f5d38e958d282 100644 (file)
@@ -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 \
index 107b359065e968bcb8898e6a8b042fe0a0185107..ad8b2c03cf800dc711c82dd752138964f8c0999b 100644 (file)
@@ -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/extra-programs-empty.test b/tests/extra-programs-empty.test
new file mode 100755 (executable)
index 0000000..992c5ee
--- /dev/null
@@ -0,0 +1,53 @@
+#! /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/>.
+
+# 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'.
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([Makefile2 Makefile3])
+AC_SUBST([prog])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+EXTRA_PROGRAMS =
+END
+
+cat > Makefile2.am <<'END'
+bin_PROGRAMS = a @prog@ b
+EXTRA_PROGRAMS =
+END
+
+cat > Makefile3.am <<'END'
+empty =
+EXTRA_PROGRAMS = $(empty)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+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
+
+:
similarity index 55%
rename from tests/subst2.test
rename to tests/programs-primary-rewritten.test
index d64d8c0a671398f0d07aa20fb796cb0ce27c75af..e52bd569af31b9f4006f04bf9101372a3c9bb714 100755 (executable)
 # 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 (executable)
index 0000000..595644e
--- /dev/null
@@ -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
+
+: