]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: split yacc6.test, for better separation and coverage
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 11 Apr 2011 14:35:59 +0000 (16:35 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 11 Apr 2011 21:21:14 +0000 (23:21 +0200)
* tests/yacc6.test: Test removed, its content extended and split
into ...
* tests/yacc-auxdir.test, tests/yacc-depend.test,
tests/yacc-line.test: ... these new tests.
* tests/yacc-depend2.test: New test, exposes the failure that
FreeBSD used to encounter in yacc6.test.
* tests/Makefile.am (TESTS): Update.

ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/yacc-auxdir.test [moved from tests/yacc6.test with 51% similarity]
tests/yacc-depend.test [new file with mode: 0755]
tests/yacc-depend2.test [new file with mode: 0755]
tests/yacc-line.test [new file with mode: 0755]

index c0495d5ada2adbcb66e7a73f1c2cbabc1018d741..08d7bc1236f6f8ea8ea9bff3bda43129c425d806 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-04-11  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       tests: split yacc6.test, for better separation and coverage
+       * tests/yacc6.test: Test removed, its content extended and split
+       into ...
+       * tests/yacc-auxdir.test, tests/yacc-depend.test,
+       tests/yacc-line.test: ... these new tests.
+       * tests/yacc-depend2.test: New test, exposes the failure that
+       FreeBSD used to encounter in yacc6.test.
+       * tests/Makefile.am (TESTS): Update.
+
 2011-04-10  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        coverage: test mixed C/C++ yacc-generated parsers in the same dir
index 3878ac91d80be4179cef8dbb2a18b6f61e300778..f14636ed76d282a376011286381c5454ac560c2f 100644 (file)
@@ -830,10 +830,13 @@ yacc.test \
 yacc2.test \
 yacc4.test \
 yacc5.test \
-yacc6.test \
 yacc7.test \
 yacc8.test \
 yaccdry.test \
+yacc-auxdir.test \
+yacc-line.test \
+yacc-depend.test \
+yacc-depend2.test \
 yacc-deleted-headers.test \
 yacc-dist-nobuild.test \
 yacc-nodist.test \
index ab0b4ee3b1dd5dde3bec96d89d802ecdf7026cc7..9839cb408fa790fccdb9d44859e415ec9a34e11c 100644 (file)
@@ -1100,10 +1100,13 @@ yacc.test \
 yacc2.test \
 yacc4.test \
 yacc5.test \
-yacc6.test \
 yacc7.test \
 yacc8.test \
 yaccdry.test \
+yacc-auxdir.test \
+yacc-line.test \
+yacc-depend.test \
+yacc-depend2.test \
 yacc-deleted-headers.test \
 yacc-dist-nobuild.test \
 yacc-nodist.test \
similarity index 51%
rename from tests/yacc6.test
rename to tests/yacc-auxdir.test
index bbb587e4296c783262386bbb226625bc3984154a..973a33807422dd01d0a13bedae49056db5b4ec97 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/>.
 
-# Test to make sure ylwrap put in right location.
+# Test to make sure ylwrap is put in right location.
 # Report from Tim Van Holder.
-# Also make sure depcomp does not needlessly update headers.
-# Report from Paolo Bonzini.
 
-required='gcc yacc GNUmake'
 . ./defs || Exit 1
 
 set -e
 
-cat > configure.in << 'END'
-AC_INIT([yacc6], [1.0])
-# `aux' is not an acceptable file/directory name on Windows systems
+mkdir aux1 sub
+
+cat > configure.in << END
+AC_INIT([$me], [1.0])
+# 'aux' is not an acceptable file/directory name on Windows systems
 AC_CONFIG_AUX_DIR([aux1])
 AM_INIT_AUTOMAKE
 AC_CONFIG_FILES([Makefile sub/Makefile])
 AC_PROG_CC
-AM_PROG_CC_C_O
 AC_PROG_YACC
-AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
 SUBDIRS = sub
-
-test-time-unchanged:
-       test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = z
-test-time-changed:
-       test `ls -1t sub/main.$(OBJEXT) z | sed 1q` = sub/main.$(OBJEXT)
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y
 END
 
-mkdir aux1 sub
-
 cat > sub/Makefile.am << 'END'
-bin_PROGRAMS = foo bar
+bin_PROGRAMS = bar
 AM_YFLAGS = -d
-foo_SOURCES = foo.y main.c
-foo_CPPFLAGS = -DFOO
 bar_SOURCES = bar.y main.c
-BUILT_SOURCES = foo.h bar.h
 END
 
-cat > sub/foo.y << 'END'
-%{
-int yylex () {return 0;}
-void yyerror (char *s) {}
-%}
-%token TOKEN
-%%
-foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
-END
-
-cp sub/foo.y sub/bar.y
-
-cat >sub/main.c <<'EOF'
-#ifdef FOO
-#  include "foo.h"
-#else
-#  include "bar.h"
-#endif
-
-int
-main()
-{
-  return 0;
-}
-EOF
-
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 test -f aux1/ylwrap
 test ! -f ylwrap
 test ! -f sub/ylwrap
+grep -i 'ylwrap' Makefile.in sub/Makefile.in # For debugging.
+$FGREP '$(top_srcdir)/aux1/ylwrap' Makefile.in
 $FGREP '$(top_srcdir)/aux1/ylwrap' sub/Makefile.in
-./configure
-$MAKE
-grep '#.*line.*foo\.y' sub/foo.c
-grep '#.*line.*bar\.y' sub/bar.c
-
-$sleep
-: > z
-$sleep
-touch sub/bar.y
-$MAKE
-$MAKE test-time-unchanged
-$sleep
-sed s/TOKEN/TEKON/g sub/bar.y >sub/bar.yt
-mv -f sub/bar.yt sub/bar.y
-$MAKE
-$MAKE test-time-changed
 
 :
diff --git a/tests/yacc-depend.test b/tests/yacc-depend.test
new file mode 100755 (executable)
index 0000000..2f708ec
--- /dev/null
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 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
+# 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/>.
+
+# Make sure depcomp does not needlessly update headers for yacc rules.
+# Report from Paolo Bonzini.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y main.c
+BUILT_SOURCES = foo.h
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token TOKEN
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+
+cat > main.c << 'END'
+#include "foo.h"
+int main(void)
+{
+  return yyparse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+$MAKE
+ls -l # For debugging.
+
+# Make sure foo.h is not updated if not really needed.
+$sleep
+: > my-timestamp
+$sleep
+touch foo.y
+$MAKE
+stat my-timestamp foo.* || : # For debugging.
+is_newest my-timestamp foo.h
+
+# Make sure foo.h is updated if needed.
+$sleep
+sed 's/TOKEN/TEKON/g' foo.y > t
+mv -f t foo.y
+$MAKE
+stat my-timestamp foo.* || : # For debugging.
+is_newest foo.h my-timestamp
+
+:
diff --git a/tests/yacc-depend2.test b/tests/yacc-depend2.test
new file mode 100755 (executable)
index 0000000..51c1fe1
--- /dev/null
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 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
+# 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/>.
+
+# Make sure depcomp does not needlessly update headers and objects
+# for yacc rules.  This test still fails with FreeBSD make (but passes
+# with NetBSD make).
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y main.c
+BUILT_SOURCES = foo.h
+.PHONY: debug-info test-time-unchanged test-time-changed
+debug-info:
+       ls -l
+       stat *.[ch] *.$(OBJEXT) my-timestamp || :
+test-time-unchanged: debug-info
+       test `ls -1t main.$(OBJEXT) my-timestamp | sed 1q` = my-timestamp
+test-time-changed: debug-info
+       test `ls -1t main.$(OBJEXT) my-timestamp | sed 1q` = main.$(OBJEXT)
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token TOKEN
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+
+cat > main.c << 'END'
+#include "foo.h"
+int main(void)
+{
+  return yyparse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+$MAKE
+ls -l # For debugging.
+
+$sleep
+: > my-timestamp
+$sleep
+touch foo.y
+$MAKE
+$MAKE test-time-unchanged
+$sleep
+sed 's/TOKEN/TEKON/g' foo.y > t
+mv -f t foo.y
+$MAKE
+$MAKE test-time-changed
+
+:
diff --git a/tests/yacc-line.test b/tests/yacc-line.test
new file mode 100755 (executable)
index 0000000..ae6dbcf
--- /dev/null
@@ -0,0 +1,111 @@
+#! /bin/sh
+# Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007, 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
+# 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 that automake yacc support ensures that yacc-generated C
+# files use correct "#line" directives.  Try also with the
+# `subdir-object' option enabled.
+
+required=yacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+mkdir dir sub sub/dir
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo bar
+AM_YFLAGS = -d
+bar_YFLAGS =
+foo_SOURCES = zardoz.y
+bar_SOURCES = dir/quux.y
+## Avoid spurious failures with Solaris make.
+zardoz.@OBJEXT@: zardoz.c
+bar-quux.@OBJEXT@: bar-quux.c
+END
+
+cat > sub/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = foo bar
+foo_YFLAGS = -d
+foo_SOURCES = zardoz.y
+bar_SOURCES = dir/quux.y
+## Avoid spurious failures with Solaris make.
+foo-zardoz.@OBJEXT@: foo-zardoz.c
+dir/quux.@OBJEXT@: dir/quux.c
+END
+
+cat > zardoz.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main(void)
+{
+  return yyparse ();
+}
+END
+
+cp zardoz.y dir/quux.y
+cp zardoz.y sub/zardoz.y
+cp zardoz.y sub/dir/quux.y
+
+c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+
+  if $vpath; then
+    srcdir=..
+    mkdir build
+    cd build
+  else
+    srcdir=.
+  fi
+
+  $srcdir/configure
+  $MAKE
+
+  # For debugging,
+  ls -l . sub sub/dir
+  $FGREP '.y' $c_outputs
+
+  $EGREP '#.*line.*(build|\.\.).*\.y' $c_outputs && Exit 1
+  # Don't be excessively strict in grepping, to avoid spurious failures.
+  grep '#.*line.*zardoz\.y' zardoz.c
+  grep '#.*line.*quux\.y' bar-quux.c
+  grep '#.*line.*zardoz\.y' sub/foo-zardoz.c
+  grep '#.*line.*quux\.y' sub/dir/quux.c
+  cd $srcdir
+
+done
+
+: