]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: more coverage on yacc/lex silent-rules, plus minor cleanups
authorStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 20 Jan 2011 00:11:51 +0000 (01:11 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 22 Jan 2011 17:22:53 +0000 (18:22 +0100)
* tests/silent-yacc-gcc.test: Add sanity checks verifying that the
generated Makefile.in files really contains the non-generic rules
we expect.  Do not redundantly manually remove files we know to be
already removed "make maintainer-clean".
(Makefile.am): Ensure we cover also non-generic yacc rules, by
setting target-specific YFLAGS.
(sub/Makefile.am): Likewise.
* tests/silent-yacc-generic.test: Likewise.
* tests/silent-lex-gcc.test: Likewise, but with LFLAGS instead of
YFLAGS.
* tests/silent-lex-generic.test: Likewise.
* tests/silent-many-gcc.test: Likewise, but with both LFLAGS and
YFLAGS.  Also ...
(do_and_check_verbose_build): Remove redundant blank line.
* tests/silent-many-generic.test: Likewise.
* tests/silent-yacc-headers.test: New test.
* tests/Makefile.am (TESTS): Update.

ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/silent-lex-gcc.test
tests/silent-lex-generic.test
tests/silent-many-gcc.test
tests/silent-many-generic.test
tests/silent-yacc-gcc.test
tests/silent-yacc-generic.test
tests/silent-yacc-headers.test [new file with mode: 0755]

index 5d2d1c0812815defd84a4805d4beb08aa300d657..331246c7753491accf5db324cf2b8b04b1d832a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-01-22   Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       tests: more coverage on yacc/lex silent-rules, plus minor cleanups
+       * tests/silent-yacc-gcc.test: Add sanity checks verifying that the
+       generated Makefile.in files really contains the non-generic rules
+       we expect.  Do not redundantly manually remove files we know to be
+       already removed "make maintainer-clean".
+       (Makefile.am): Ensure we cover also non-generic yacc rules, by
+       setting target-specific YFLAGS.
+       (sub/Makefile.am): Likewise.
+       * tests/silent-yacc-generic.test: Likewise.
+       * tests/silent-lex-gcc.test: Likewise, but with LFLAGS instead of
+       YFLAGS.
+       * tests/silent-lex-generic.test: Likewise.
+       * tests/silent-many-gcc.test: Likewise, but with both LFLAGS and
+       YFLAGS.  Also ...
+       (do_and_check_verbose_build): Remove redundant blank line.
+       * tests/silent-many-generic.test: Likewise.
+       * tests/silent-yacc-headers.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+
 2011-01-22  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests: fix spurious failures in yflags*.test
index 39f1a39923dca28870daa9b7af79f284a26e36ed..e639b6c68c761b270ac516aab204b1ed48a1e78a 100644 (file)
@@ -648,6 +648,7 @@ silent-lex-gcc.test \
 silent-lex-generic.test \
 silent-yacc-gcc.test \
 silent-yacc-generic.test \
+silent-yacc-headers.test \
 sinclude.test \
 srcsub.test \
 srcsub2.test \
index 0ea9825cc8bba3cc29f3041969bb15405ac1abbf..5eedb768626495c782aa7240cdd0c767b43f31fa 100644 (file)
@@ -915,6 +915,7 @@ silent-lex-gcc.test \
 silent-lex-generic.test \
 silent-yacc-gcc.test \
 silent-yacc-generic.test \
+silent-yacc-headers.test \
 sinclude.test \
 srcsub.test \
 srcsub2.test \
index 426dc504cc4fd24e5a1ac943a7b70eebf1081e7e..75503933aaf4fa51598493619d216713481b2b1b 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2010 Free Software Foundation, Inc.
+# Copyright (C) 2010, 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
@@ -37,6 +37,7 @@ cat > Makefile.am <<'EOF'
 bin_PROGRAMS = foo1 foo2
 foo1_SOURCES = foo.l
 foo2_SOURCES = $(foo1_SOURCES)
+foo2_LFLAGS = -n
 foo2_CFLAGS = $(AM_CFLAGS)
 SUBDIRS = sub
 LDADD = $(LEXLIB)
@@ -48,6 +49,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = bar1 bar2
 bar1_SOURCES = bar.l
 bar2_SOURCES = $(bar1_SOURCES)
+bar2_LFLAGS = -n
 bar2_CFLAGS = $(AM_CFLAGS)
 LDADD = $(LEXLIB)
 EOF
@@ -64,6 +66,10 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in
+$FGREP 'bar2-bar.c' sub/Makefile.in
+
 # Force gcc ("fast") depmode.
 # This apparently useless "for" loop is here to simplify the syncing
 # with sister test `silent-lex-gcc.test'.
@@ -108,7 +114,7 @@ do
 
   # Ensure a truly clean rebuild.
   $MAKE clean
-  rm -f foo.c sub/bar.c
+  rm -f *foo.c sub/*bar.c
 
   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
   cat stdout
@@ -136,7 +142,6 @@ do
   # Ensure a truly clean reconfiguration/rebuild.
   $MAKE clean
   $MAKE maintainer-clean
-  rm -f foo.c sub/bar.c
 
 done
 
index 66535e800a4a0aa05a42b4655f915e0e20caae8e..532232633914a2a84c9479faf724a9eb1e416fe4 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2010 Free Software Foundation, Inc.
+# Copyright (C) 2010, 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
@@ -37,6 +37,7 @@ cat > Makefile.am <<'EOF'
 bin_PROGRAMS = foo1 foo2
 foo1_SOURCES = foo.l
 foo2_SOURCES = $(foo1_SOURCES)
+foo2_LFLAGS = -n
 foo2_CFLAGS = $(AM_CFLAGS)
 SUBDIRS = sub
 LDADD = $(LEXLIB)
@@ -48,6 +49,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = bar1 bar2
 bar1_SOURCES = bar.l
 bar2_SOURCES = $(bar1_SOURCES)
+bar2_LFLAGS = -n
 bar2_CFLAGS = $(AM_CFLAGS)
 LDADD = $(LEXLIB)
 EOF
@@ -64,6 +66,10 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in
+$FGREP 'bar2-bar.c' sub/Makefile.in
+
 # Force dependency tracking explicitly, so that slow dependency
 # extractors are not rejected.  Try also with dependency tracking
 # explicitly disabled.
@@ -108,7 +114,7 @@ do
 
   # Ensure a truly clean rebuild.
   $MAKE clean
-  rm -f foo.c sub/bar.c
+  rm -f *foo.c sub/*bar.c
 
   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
   cat stdout
@@ -136,7 +142,6 @@ do
   # Ensure a truly clean reconfiguration/rebuild.
   $MAKE clean
   $MAKE maintainer-clean
-  rm -f foo.c sub/bar.c
 
 done
 
index 5e6d191ae19ba4e76027edc5fa8f184bfffb0c78..1732d9d817e9237701f73a26a594c174550454ab 100755 (executable)
@@ -73,7 +73,6 @@ do_and_check_silent_build ()
 # Avoids too much code duplication.
 do_and_check_verbose_build ()
 {
-
   case $1 in
     --rebuild) rebuild=true;;
             *) rebuild=false;;
@@ -118,6 +117,8 @@ fo2_SOURCES = $(foo_SOURCES)
 fo2_CPPFLAGS = $(AM_CPPFLAGS)
 fo2_FFLAGS = $(AM_FFLAGS)
 fo2_FCFLAGS = $(AM_FCFLAGS)
+fo2_YFLAGS = -v
+fo2_LFLAGS = -n
 SUBDIRS = sub
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
@@ -134,6 +135,8 @@ ba2_SOURCES = $(baz_SOURCES)
 ba2_CPPFLAGS = $(AM_CPPFLAGS)
 ba2_FFLAGS = $(AM_FFLAGS)
 ba2_FCFLAGS = $(AM_FCFLAGS)
+ba2_YFLAGS = -v
+ba2_LFLAGS = -n
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
 BUILT_SOURCES = baz6.h
@@ -182,6 +185,12 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Ensure per-target rules are used, to ensure their coverage below.
+# (We do not do an exhaustive check, that wouldn't be practical).
+$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'fo2-foo5.c' Makefile.in
+$FGREP 'fo2-foo6.c' Makefile.in
+
 # Force gcc ("fast") depmode.
 # This apparently useless "for" loop is here to simplify the syncing
 # with sister test `silent-many-gcc.test'.
@@ -202,7 +211,7 @@ do
   $MAKE clean
   # This is required, since these files are not removed by `make clean'
   # (as dictated by the GNU Coding Standards).
-  rm -f foo5.c foo6.[ch] sub/baz5.c sub/baz6.[ch]
+  rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
 
   do_and_check_verbose_build
   # Cleaning and then rebuilding with the same V flag (and without
index ed2744836844e263c4a9c7963fde5cde6e6546d9..0502bf88a1060be59f22d594d8d216792ea7b38d 100755 (executable)
@@ -75,7 +75,6 @@ do_and_check_silent_build ()
 # Avoids too much code duplication.
 do_and_check_verbose_build ()
 {
-
   case $1 in
     --rebuild) rebuild=true;;
             *) rebuild=false;;
@@ -120,6 +119,8 @@ fo2_SOURCES = $(foo_SOURCES)
 fo2_CPPFLAGS = $(AM_CPPFLAGS)
 fo2_FFLAGS = $(AM_FFLAGS)
 fo2_FCFLAGS = $(AM_FCFLAGS)
+fo2_YFLAGS = -v
+fo2_LFLAGS = -n
 SUBDIRS = sub
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
@@ -136,6 +137,8 @@ ba2_SOURCES = $(baz_SOURCES)
 ba2_CPPFLAGS = $(AM_CPPFLAGS)
 ba2_FFLAGS = $(AM_FFLAGS)
 ba2_FCFLAGS = $(AM_FCFLAGS)
+ba2_YFLAGS = -v
+ba2_LFLAGS = -n
 AM_YFLAGS = -d
 LDADD = $(LEXLIB)
 BUILT_SOURCES = baz6.h
@@ -184,6 +187,12 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Ensure per-target rules are used, to ensure their coverage below.
+# (We do not do an exhaustive check, that wouldn't be practical).
+$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'fo2-foo5.c' Makefile.in
+$FGREP 'fo2-foo6.c' Makefile.in
+
 # Force dependency tracking explicitly, so that slow dependency
 # extractors are not rejected.  Try also with dependency tracking
 # explicitly disabled.
@@ -204,7 +213,7 @@ do
   $MAKE clean
   # This is required, since these files are not removed by `make clean'
   # (as dictated by the GNU Coding Standards).
-  rm -f foo5.c foo6.[ch] sub/baz5.c sub/baz6.[ch]
+  rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
 
   do_and_check_verbose_build
   # Cleaning and then rebuilding with the same V flag (and without
index 83e6ebee2ffb9d37dd97ede01f07140e55830911..a1f2ae6fac286ded9d6047514df3a0f4ac83f1fd 100755 (executable)
@@ -37,6 +37,7 @@ cat > Makefile.am <<'EOF'
 bin_PROGRAMS = foo1 foo2
 foo1_SOURCES = foo.y
 foo2_SOURCES = $(foo1_SOURCES)
+foo2_YFLAGS = -v
 foo2_CFLAGS = $(AM_CPPFLAGS)
 SUBDIRS = sub
 EOF
@@ -47,6 +48,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = bar1 bar2
 bar1_SOURCES = bar.y
 bar2_SOURCES = $(bar1_SOURCES)
+bar2_YFLAGS = -v
 bar2_CFLAGS = $(AM_CPPFLAGS)
 EOF
 
@@ -66,6 +68,10 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in
+$FGREP 'bar2-bar.c' sub/Makefile.in
+
 # Force gcc ("fast") depmode.
 # This apparently useless "for" loop is here to simplify the syncing
 # with sister test `silent-yacc-gcc.test'.
@@ -110,7 +116,7 @@ do
 
   # Ensure a truly clean rebuild.
   $MAKE clean
-  rm -f foo.[ch] sub/bar.[ch]
+  rm -f *foo.[ch] sub/*bar.[ch]
 
   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
   cat stdout
@@ -138,7 +144,6 @@ do
   # Ensure a truly clean reconfiguration/rebuild.
   $MAKE clean
   $MAKE maintainer-clean
-  rm -f foo.[ch] sub/bar.[ch]
 
 done
 
index 553e78bc589770bedae6960c9fa8daf13b557964..52a98a813c66e7612d144f5dc2fa7b7354a0398b 100755 (executable)
@@ -37,6 +37,7 @@ cat > Makefile.am <<'EOF'
 bin_PROGRAMS = foo1 foo2
 foo1_SOURCES = foo.y
 foo2_SOURCES = $(foo1_SOURCES)
+foo2_YFLAGS = -v
 foo2_CFLAGS = $(AM_CPPFLAGS)
 SUBDIRS = sub
 EOF
@@ -47,6 +48,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 bin_PROGRAMS = bar1 bar2
 bar1_SOURCES = bar.y
 bar2_SOURCES = $(bar1_SOURCES)
+bar2_YFLAGS = -v
 bar2_CFLAGS = $(AM_CPPFLAGS)
 EOF
 
@@ -66,6 +68,10 @@ $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
 
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in
+$FGREP 'bar2-bar.c' sub/Makefile.in
+
 # Force dependency tracking explicitly, so that slow dependency
 # extractors are not rejected.  Try also with dependency tracking
 # explicitly disabled.
@@ -110,7 +116,7 @@ do
 
   # Ensure a truly clean rebuild.
   $MAKE clean
-  rm -f foo.[ch] sub/bar.[ch]
+  rm -f *foo.[ch] sub/*bar.[ch]
 
   $MAKE V=1 >stdout || { cat stdout; Exit 1; }
   cat stdout
@@ -138,7 +144,6 @@ do
   # Ensure a truly clean reconfiguration/rebuild.
   $MAKE clean
   $MAKE maintainer-clean
-  rm -f foo.[ch] sub/bar.[ch]
 
 done
 
diff --git a/tests/silent-yacc-headers.test b/tests/silent-yacc-headers.test
new file mode 100755 (executable)
index 0000000..f8dd99e
--- /dev/null
@@ -0,0 +1,175 @@
+#!/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/>.
+
+# Check silent-rules mode for Yacc, when yacc-generated headers are
+# involved (i.e., the `-d' option is in *YFLAGS).
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub
+
+cat >>configure.in <<'EOF'
+AM_SILENT_RULES
+AC_PROG_YACC
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+AM_YFLAGS = -d
+bin_PROGRAMS = foo bar
+foo_SOURCES = parse.y
+bar_SOURCES = $(foo_SOURCES)
+bar_YFLAGS = $(AM_YFLAGS)
+EOF
+
+cat > parse.y <<'EOF'
+%{
+void yyerror (char *s) { return; }
+int yylex (void) { return 0; }
+int main (void) { return 0; }
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+EOF
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Check that the expected non-generic rules has been truly generated.
+# Otherwise, the coverage offered by this test will be weaker then
+# expected and planned.
+$FGREP 'bar-parse.c' Makefile.in
+$FGREP '$(bar_YFLAGS)' Makefile.in
+
+./configure --enable-silent-rules
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC  *parse\.c' stdout
+grep 'updating  *parse\.h' stdout
+grep 'YACC  *bar-parse\.c' stdout
+grep 'updating  *bar-parse\.h' stdout
+
+grep ' CC  *parse\.' stdout
+grep ' CC  *bar-parse\.' stdout
+grep 'CCLD  *foo' stdout
+grep 'CCLD  *bar' stdout
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC  *parse\.c' stdout
+grep 'updating  *parse\.h' stdout
+grep 'YACC  *bar-parse\.c' stdout
+grep 'updating  *bar-parse\.h' stdout
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+# Don't look for "YACC *.c" and "updating *.h", as yacc shouldn't
+# have been re-run.
+grep ' CC  *parse\.' stdout
+grep ' CC  *bar-parse\.' stdout
+grep 'CCLD  *foo' stdout
+grep 'CCLD  *bar' stdout
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC  *parse\.c' stdout
+grep 'updating  *parse\.h' stdout
+grep 'YACC  *bar-parse\.c' stdout
+grep 'updating  *bar-parse\.h' stdout
+
+# Ensure a truly clean rebuild.
+$MAKE maintainer-clean
+
+./configure --enable-silent-rules
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE V=1 parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+grep 'YACC' stdout && Exit 1
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+# Don't look for ylwrap, as probably lex hasn't been re-run.
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE V=1 parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+grep 'YACC' stdout && Exit 1
+
+: