automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] {yacc-work} coverage: test mixed C/C++ yacc-generated parser


From: Stefano Lattarini
Subject: Re: [PATCH] {yacc-work} coverage: test mixed C/C++ yacc-generated parsers in the same dir
Date: Sun, 10 Apr 2011 14:50:28 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

On Sunday 10 April 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Sun, Apr 10, 2011 at 12:57:26PM CEST:
> > A final testcase I'd like to check in before submitting the final
> > patch for automake bug#7648 and PR automake/491 (patch not yet
> > complete ATM, but I think I'm almost there).  It checks that many
> > different Yacc parsers (both C and C++) can co-exists in the same
> > directory.
> > 
> > OK for yacc-work?  I will push in 72 hours if there is no objection.
> 
> OK, a couple of minor nits.
> 
> Thanks,
> Ralf
> 
> > Subject: [PATCH] coverage: test mixed C/C++ yacc-generated parsers in the 
> > same dir
> > 
> > * tests/yacc-mix-c-cxx.test: New test.
> > * tests/Makefile.am (TESTS): Update.
> 
> > --- /dev/null
> > +++ b/tests/yacc-mix-c-cxx.test
> 
> > +# Check that many different Yacc parsers (both C and C++) can co-exists
> > +# in the same directory.
> > +
> > +required=yacc
> > +. ./defs || Exit 1
> > +
> > +set -e
> > +
> > +distdir=$me-1.0
> > +
> > +cat >> configure.in << 'END'
> > +AC_PROG_CC
> > +AC_PROG_CXX
> > +AC_PROG_YACC
> > +AC_OUTPUT
> > +END
> > +
> > +cat > Makefile.am << 'END'
> > +bin_PROGRAMS = c1 c2 cxx1 cxx2 cxx3
> > +AM_YFLAGS = -d
> > +
> > +c1_SOURCES = p.y p.h 1.c
> > +c2_SOURCES = p.y 2.c
> > +c2_YFLAGS =
> > +
> > +cxx1_SOURCES = parse.yy main1.cc parse.hh
> > +
> > +cxx2_SOURCES = parse2.y++ main2.c++
> > +cxx2_YFLAGS =
> > +
> > +cxx3_SOURCES = parse3.yxx main3.cxx
> > +BUILT_SOURCES = parse3.hxx
> > +END
> > +
> > +# The content of all the .c and .y files created below is valid C but
> > +# deliberately invalid as C++.
> 
> s/as //  I think.
> 
Yes, thanks for catching that.

> > +# Vice versa, the content of all the .c++, .cxx, .cc, .y++, .yxx and
> > +# .yy files created below is valid C++ but deliberately invalid C.
> > +
> > +cat > p.y <<'END'
> > +%{
> > +int yylex (void) { int new = 0; return new; }
> > +void yyerror (char *s) { return; }
> > +%}
> > +%token ZARDOZ
> > +%%
> > +x : 'x' {};
> > +%%
> > +END
> > +
> > +cat > 1.c <<'END'
> > +#include "p.h"
> > +int main ()
> > +{
> > +    int new = ZARDOZ;
> > +    return yyparse () + new;
> > +}
> > +
> > +END
> > +
> > +cat > 2.c <<'END'
> > +int main ()
> > +{
> > +    int yyparse ();
> > +    int new = 0;
> > +    return yyparse () + new;
> > +}
> > +END
> > +
> > +cat > parse.yy <<'END'
> > +%{
> > +#include <cstdlib>
> > +#include "parse.hh"
> > +int yylex (void) { return 0; }
> > +void yyerror (const char *s) { return; }
> > +%}
> > +%token FOOBAR
> > +%%
> > +x : 'x' {};
> > +%%
> > +END
> > +
> > +cat > parse2.y++ <<'END'
> > +%{
> > +#include <cstdlib>
> > +int yylex (void) { return 0; }
> > +void yyerror (const char *s) { return; }
> > +%}
> > +%%
> > +x : 'x' {};
> > +%%
> > +END
> > +
> > +cat > main1.cc <<'END'
> > +using namespace std;
> > +#include "parse.hh"
> > +int main (int argc, char **argv)
> > +{
> > +    int yyparse (void);
> > +    return yyparse () + FOOBAR;
> > +}
> > +END
> > +
> > +cat > main2.c++ <<'END'
> > +using namespace std;
> > +int main (int argc, char **argv)
> > +{
> > +    int yyparse (void);
> > +    return yyparse ();
> > +}
> > +END
> > +
> > +edit () { sed -e 's/FOOBAR/BAZQUUX/' -e 's/"parse\.hh"/"parse3.hxx"/'; }
> > +edit <parse.yy >parse3.yxx
> > +edit <main1.cc >main3.cxx
> > +
> > +$ACLOCAL
> > +$AUTOCONF
> > +$AUTOMAKE -a
> > +
> > +./configure
> > +
> > +$MAKE
> > +ls -l # For debugging.
> > +
> > +test -f p.c
> > +test -f p.h
> > +test -f c2-p.c
> > +test ! -r c2-p.h
> > +
> > +test -f parse.cc
> > +test -f parse.hh
> > +test -f parse3.cxx
> > +test -f parse3.hxx
> > +
> > +test -f cxx2-parse2.c++
> > +test ! -r parse2.h++
> > +test ! -r cxx2-parse2.h++
> > +
> > +# Minimal checks about recovering from header removal.
> > +rm -f p.h parse.hh parse3.hxx
> > +$MAKE p.h parse.hh
> > +test -f p.h
> > +test -f parse.hh
> > +test ! -r parse3.hxx
> > +$MAKE
> > +test -f parse3.hxx
> 
> I think it would make sense to also do parallel build tests here
>
Agreed (and BTW this uncovered a bug in the testcase: I had forgotten
to add `p.h' and `parse.hh' to BUILT_SOURCES in the Makefile.am; it's
fixed now).

Here is what we could do IMHO: first try a VPATH serial build, then
an in-tree parallel build.  See the attached squash-in.

Tested with GNU make (3.80, 3.81, 3.82), FreeBSD and NetBSD make
(Debian ports), Heirloom make, Solaris XPG4 and CCS make, and
Solaris dmake.  OK?

> (only if make is GNU make, of course)
>
Why?  I've never found a make implementation rejecting the `-j' option.
That I know of (but I might be mistaken here), in the worst case, the
`-j' option is simply ignored (as with, e.g., Solaris XPG4 and CCS make,
which BTW nicely warn the user about the fact that they'll run only one
job at the time).

Thanks,
  Stefano
diff --git a/tests/yacc-mix-c-cxx.test b/tests/yacc-mix-c-cxx.test
index 6795c92..0901ac8 100755
--- a/tests/yacc-mix-c-cxx.test
+++ b/tests/yacc-mix-c-cxx.test
@@ -45,11 +45,12 @@ cxx2_SOURCES = parse2.y++ main2.c++
 cxx2_YFLAGS =
 
 cxx3_SOURCES = parse3.yxx main3.cxx
-BUILT_SOURCES = parse3.hxx
+
+BUILT_SOURCES = p.h parse.hh parse3.hxx
 END
 
 # The content of all the .c and .y files created below is valid C but
-# deliberately invalid as C++.
+# deliberately invalid C++.
 # Vice versa, the content of all the .c++, .cxx, .cc, .y++, .yxx and
 # .yy files created below is valid C++ but deliberately invalid C.
 
@@ -134,32 +135,61 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-./configure
-
-$MAKE
-ls -l # For debugging.
-
-test -f p.c
-test -f p.h
-test -f c2-p.c
-test ! -r c2-p.h
-
-test -f parse.cc
-test -f parse.hh
-test -f parse3.cxx
-test -f parse3.hxx
-
-test -f cxx2-parse2.c++
-test ! -r parse2.h++
-test ! -r cxx2-parse2.h++
-
-# Minimal checks about recovering from header removal.
-rm -f p.h parse.hh parse3.hxx
-$MAKE p.h parse.hh
-test -f p.h
-test -f parse.hh
-test ! -r parse3.hxx
-$MAKE
-test -f parse3.hxx
+# Try a VPATH and by default serial build first, and then an in-tree
+# and by default parallel build.
+
+for try in 0 1; do
+
+  if test $try -eq 0; then
+    mkdir build
+    cd build
+    srcdir=..
+    debug_info="ls -l . $srcdir"
+    run_make=$MAKE
+  elif test $try -eq 1; then
+    srcdir=.
+    debug_info="ls -l"
+    case $MAKE in
+      *\ -j*) run_make=$MAKE;;
+      *) run_make="$MAKE -j 3";;
+    esac
+  else
+    echo "$me: invalid value of \$try '$try'" >&2
+    Exit 99
+  fi
+
+  $srcdir/configure
+
+  $run_make
+  $debug_info
+
+  test -f p.c
+  test -f p.h
+  test -f c2-p.c
+  test ! -r c2-p.h
+
+  test -f parse.cc
+  test -f parse.hh
+  test -f parse3.cxx
+  test -f parse3.hxx
+
+  test -f cxx2-parse2.c++
+  test ! -r parse2.h++
+  test ! -r cxx2-parse2.h++
+
+  # Minimal checks about recovering from header removal.
+  rm -f p.h parse.hh parse3.hxx
+  $run_make p.h parse.hh
+  $debug_info
+  test -f p.h
+  test -f parse.hh
+  test ! -r parse3.hxx
+  $run_make
+  $debug_info
+  test -f parse3.hxx
+
+  cd $srcdir
+
+done
 
 :

reply via email to

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