automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] {yacc-work} tests: more coverage on yacc/lex silent-rules, p


From: Stefano Lattarini
Subject: Re: [PATCH] {yacc-work} tests: more coverage on yacc/lex silent-rules, plus minor cleanups
Date: Sat, 22 Jan 2011 12:28:58 +0100
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

On Friday 21 January 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Fri, Jan 21, 2011 at 01:16:35PM CET:
> > The `silent-yacc*.test' and `silent-lex*.test' tests were testing
> > non-generic rules for C sources only, not for Lex/Yacc sources.
> > 
> > Also, the output emitted by automake-generated rules when updating
> > a yacc-generated header wasn't being tested anywhere.
> 
> AFAICS it still isn't fully, even after this patch: you don't trigger
> the "recover from removal of header" rule anywhere.
>
Ouch.

> And if that wasn't the point of the new test in this patch,
>
Basically it was (or intended to be), since the "recover from header
removal" is in fact the only code path in Yacc support that runs when
`-d' is *YFLAGS, but not otherwise.

But apparently I lose the focus while writing the patch, and messed
up; sorry for the sloppiness.

> then I don't see any reason to add that new test; it can just
> be dropped.
>
I've fixed it now.  See the attached amended patch -- BTW, sorry if
there's not also a squashed-in diff, but I managed to lose that :-(

> > The attached patch should fix these shortcomings.
> > 
> > OK for the 'yacc-work' branch (branch which, BTW, might as well
> > be made public at this point), to be merged into 'master'?
> 
> With above issue and nits below addressed.
> 
> > Subject: [PATCH] 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 remove by hand 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.
> 
> > --- a/tests/silent-lex-gcc.test
> > +++ b/tests/silent-lex-gcc.test
> 
> > @@ -64,6 +66,18 @@ $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.
> 
> s/has been truly/actually have been/
> s/then/than/
> 
> Ugh.  How about this shorter but yet more detailed comment instead?
> 
> # Ensure per-target rules are used, to ensure their coverage below.
>
Sure; shorter and clearer is always nicer :-)

> Same in the other tests where this comment has been added.
> 
> > +$FGREP 'foo2-foo.c' Makefile.in
> > +$FGREP 'foo2-foo2-foo.o' Makefile.in
> > +$FGREP '$(foo2_LFLAGS)' Makefile.in
> > +$FGREP '$(foo2_CFLAGS)' Makefile.in
> > +$FGREP 'bar2-bar.c' sub/Makefile.in
> > +$FGREP 'bar2-bar2-bar.o' sub/Makefile.in
> > +$FGREP '$(bar2_LFLAGS)' sub/Makefile.in
> > +$FGREP '$(bar2_CFLAGS)' sub/Makefile.in
> 
> Do you *really* think you need to do all of these greps to ensure that
> things are actually working the same way they have for the last decade?
>
Well, not really, but I've become more suspicious since I realised
that, after my recent commit v1.11-268-g3544a43 "yacc: support variable
expansions in *YFLAGS definition", the usual idiom to force a "fake"
yacc compilation with per-object flags:
  bin_PROGRAMS = foo
  foo_SOURCES = foo.y
  foo_YFLAGS = $(AM_YFLAGS)
does not work anymore (even if it has for the last decade ;->)
But maybe I'm being just too paranoid now, and I have to admit that I
got a bit carried away while writing the above.

> Won't just one, or maybe two, suffice?
>
I guess so; I'll go for these:
 $FGREP 'foo2-foo.c' Makefile.in
 $FGREP 'bar2-bar.c' Makefile.in

> I mean, come on, the only thing
> I can see coming from this is that, if there ever arises the need to
> change the object file naming, the person doing that change will be
> cursing no end when they have to adjust such a lot of code.  No bug will
> ever be fixed or avoided from this.
>
Agreed.

> Same for all the other tests.
>
Yes.  See the attached amended patch (again, sorry for the lack of
squash-in diffs).

> >  # Force gcc ("fast") depmode.
> >  # This apparently useless "for" loop is here to simplify the syncing
> >  # with sister test `silent-lex-gcc.test'.
> 
> [...]
> 
> > --- /dev/null
> > +++ b/tests/silent-yacc-headers.test
> 
> > +# Check silent-rules mode for Yacc, when used with the `-d' option.
> > +# Keep this in sync with sister test `silent-yacc-d-gcc.test'.
> > +
> > +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) {}
> > +int yylex (void) {return 0;}
> > +int main(void) {return 0;}
> 
> int main (void) { return 0; }
> similar above
>
Oops. fixed.

> > +%}
> > +%token EOF
> > +%%
> > +fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
> > +EOF
> 

The updated patch is attached.  I will push to 'yacc-work'
shortly if there are no more objections.

Thanks,
  Stefano
From b1749a913ca1b1d2a7fea335f4440f08c78a18a9 Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Thu, 20 Jan 2011 01:11:51 +0100
Subject: [PATCH] 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 remove by hand 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                      |   21 +++++
 tests/Makefile.am              |    1 +
 tests/Makefile.in              |    1 +
 tests/silent-lex-gcc.test      |   11 ++-
 tests/silent-lex-generic.test  |   11 ++-
 tests/silent-many-gcc.test     |   13 +++-
 tests/silent-many-generic.test |   13 +++-
 tests/silent-yacc-gcc.test     |    9 ++-
 tests/silent-yacc-generic.test |    9 ++-
 tests/silent-yacc-headers.test |  175 ++++++++++++++++++++++++++++++++++++++++
 10 files changed, 250 insertions(+), 14 deletions(-)
 create mode 100755 tests/silent-yacc-headers.test

diff --git a/ChangeLog b/ChangeLog
index 3f23906..733d935 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
 2011-01-22   Stefano Lattarini  <address@hidden>
 
+       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 remove by hand 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  <address@hidden>
+
        tests: cover yacc target-specific flags, and `-v' flag handling
        * tests/yacc-basic.test: Also try to build a parser having `-v'
        as target-specific flags.  Add a couple of `ls -l' commands, for
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 39f1a39..e639b6c 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 0ea9825..5eedb76 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 426dc50..7550393 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 66535e8..5322326 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 5e6d191..0333daa 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 would be impractical).
+$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 ed27448..9a40374 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 would be impractical).
+$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 83e6ebe..a1f2ae6 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 553e78b..52a98a8 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 0000000..f8dd99e
--- /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 <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
+
+:
-- 
1.7.2.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]