From: Stefano Lattarini Date: Thu, 20 Jan 2011 00:11:51 +0000 (+0100) Subject: tests: more coverage on yacc/lex silent-rules, plus minor cleanups X-Git-Tag: ylwrap-refactor-abandoned-branch~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0283a956cd5f0a4522e2c3f1fa7155944464348e;p=thirdparty%2Fautomake.git 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. --- diff --git a/ChangeLog b/ChangeLog index 5d2d1c081..331246c77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2011-01-22 Stefano Lattarini + + 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 tests: fix spurious failures in yflags*.test diff --git a/tests/Makefile.am b/tests/Makefile.am index 39f1a3992..e639b6c68 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 0ea9825cc..5eedb7686 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 \ diff --git a/tests/silent-lex-gcc.test b/tests/silent-lex-gcc.test index 426dc504c..75503933a 100755 --- a/tests/silent-lex-gcc.test +++ b/tests/silent-lex-gcc.test @@ -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 diff --git a/tests/silent-lex-generic.test b/tests/silent-lex-generic.test index 66535e800..532232633 100755 --- a/tests/silent-lex-generic.test +++ b/tests/silent-lex-generic.test @@ -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 diff --git a/tests/silent-many-gcc.test b/tests/silent-many-gcc.test index 5e6d191ae..1732d9d81 100755 --- a/tests/silent-many-gcc.test +++ b/tests/silent-many-gcc.test @@ -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 diff --git a/tests/silent-many-generic.test b/tests/silent-many-generic.test index ed2744836..0502bf88a 100755 --- a/tests/silent-many-generic.test +++ b/tests/silent-many-generic.test @@ -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 diff --git a/tests/silent-yacc-gcc.test b/tests/silent-yacc-gcc.test index 83e6ebee2..a1f2ae6fa 100755 --- a/tests/silent-yacc-gcc.test +++ b/tests/silent-yacc-gcc.test @@ -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 diff --git a/tests/silent-yacc-generic.test b/tests/silent-yacc-generic.test index 553e78bc5..52a98a813 100755 --- a/tests/silent-yacc-generic.test +++ b/tests/silent-yacc-generic.test @@ -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 index 000000000..f8dd99e35 --- /dev/null +++ b/tests/silent-yacc-headers.test @@ -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 . + +# 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 + +: