From eb7adcd2b2911e26792000bc89e09894b182f323 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Fri, 7 Jan 2011 20:52:17 +0100 Subject: [PATCH] yacc: more tests on *YFLAGS support * tests/yflags-var-expand.test: New test, still xfailing. It exposes automake bug#7800 -- "automake fails to honor `-d' in AM_YFLAGS when variable expansions are involved". * tests/yflags-d-false-positive.test: New test, checking that automake do not spuriously see `-d' in *YFLAGS when that isn't really there. * tests/yflags-force-override.test: New test, checking that automake can cope with definition of the YFLAGS variable in Makefile.am (even if that is an extremely bad practice, as that variable is user-reserved). * tests/yflags-cmdline-override.test: New test, checking that automake can cope with user-redefinition of YFLAGS at configure time and/or at make time. * tests/yflags-conditional.test: New test, checks that automake warns on conditionally-defined *YFLAGS variables. * tests/Makefile.am (TESTS, XFAIL_TESTS): Update. --- ChangeLog | 20 +++++++ tests/Makefile.am | 6 ++ tests/Makefile.in | 6 ++ tests/yflags-cmdline-override.test | 90 +++++++++++++++++++++++++++++ tests/yflags-conditional.test | 46 +++++++++++++++ tests/yflags-d-false-positives.test | 43 ++++++++++++++ tests/yflags-force-override.test | 66 +++++++++++++++++++++ tests/yflags-var-expand.test | 63 ++++++++++++++++++++ 8 files changed, 340 insertions(+) create mode 100755 tests/yflags-cmdline-override.test create mode 100755 tests/yflags-conditional.test create mode 100755 tests/yflags-d-false-positives.test create mode 100755 tests/yflags-force-override.test create mode 100755 tests/yflags-var-expand.test diff --git a/ChangeLog b/ChangeLog index d05135f63..8f6d3aede 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2011-01-08 Stefano Lattarini + + yacc: more tests on *YFLAGS support + * tests/yflags-var-expand.test: New test, still xfailing. It + exposes automake bug#7800 -- "automake fails to honor `-d' in + AM_YFLAGS when variable expansions are involved". + * tests/yflags-d-false-positive.test: New test, checking that + automake do not spuriously see `-d' in *YFLAGS when that isn't + really there. + * tests/yflags-force-override.test: New test, checking that + automake can cope with definition of the YFLAGS variable in + Makefile.am (even if that is an extremely bad practice, as that + variable is user-reserved). + * tests/yflags-cmdline-override.test: New test, checking that + automake can cope with user-redefinition of YFLAGS at configure + time and/or at make time. + * tests/yflags-conditional.test: New test, checks that automake + warns on conditionally-defined *YFLAGS variables. + * tests/Makefile.am (TESTS, XFAIL_TESTS): Update. + 2011-01-08 Stefano Lattarini yacc: extend and improve tests diff --git a/tests/Makefile.am b/tests/Makefile.am index 15d3b2865..490c4660b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,6 +21,7 @@ all.test \ auxdir2.test \ cond17.test \ gcj6.test \ +yflags-var-expand.test \ txinfo5.test include $(srcdir)/parallel-tests.am @@ -813,6 +814,11 @@ yaccvpath.test \ yacc-d-vpath.test \ yflags.test \ yflags2.test \ +yflags-cmdline-override.test \ +yflags-conditional.test \ +yflags-d-false-positives.test \ +yflags-force-override.test \ +yflags-var-expand.test \ $(parallel_tests) EXTRA_DIST = ChangeLog-old gen-parallel-tests $(TESTS) diff --git a/tests/Makefile.in b/tests/Makefile.in index 6233b8240..0addaf639 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -277,6 +277,7 @@ all.test \ auxdir2.test \ cond17.test \ gcj6.test \ +yflags-var-expand.test \ txinfo5.test parallel_tests = \ @@ -1080,6 +1081,11 @@ yaccvpath.test \ yacc-d-vpath.test \ yflags.test \ yflags2.test \ +yflags-cmdline-override.test \ +yflags-conditional.test \ +yflags-d-false-positives.test \ +yflags-force-override.test \ +yflags-var-expand.test \ $(parallel_tests) EXTRA_DIST = ChangeLog-old gen-parallel-tests $(TESTS) diff --git a/tests/yflags-cmdline-override.test b/tests/yflags-cmdline-override.test new file mode 100755 index 000000000..86c35832e --- /dev/null +++ b/tests/yflags-cmdline-override.test @@ -0,0 +1,90 @@ +#! /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 that automake can cope with user-redefinition of $(YFLAGS) +# at configure time and/or at make time. + +required=yacc +. ./defs || Exit 1 + +set -e + +unset YFLAGS || : + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_YACC +AC_OUTPUT +END + +cat > Makefile.am <<'END' +bin_PROGRAMS = foo +foo_SOURCES = foo.y +# A minor automake wart: automake doesn't generate code to clean +# `*.output' files generated by yacc (it's not even clear if that +# would be useful in general, so it's probably better to be +# conservative). +CLEANFILES = foo.output +# Another automake wart: `-d' flag won't be given at automake time, +# so automake won't be able to generate code to clean `foo.h' :-( +MAINTAINERCLEANFILES = foo.h +END + +cat > foo.y << 'END' +%{ +int yylex () { return 0; } +void yyerror (char *s) { return; } +int main () { return 0; } +%} +%% +foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; +END + +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF + +./configure YFLAGS='-d -v' +$MAKE +ls -l +test -f foo.c +test -f foo.h +test -f foo.output + +$MAKE maintainer-clean +ls -l + +./configure YFLAGS='-v' +$MAKE +ls -l +test -f foo.c +test ! -r foo.h +test -f foo.output + +$MAKE maintainer-clean +ls -l + +./configure YFLAGS='-v' +YFLAGS=-d $MAKE -e +ls -l +test -f foo.c +test -f foo.h +test ! -r foo.output + +$MAKE maintainer-clean +ls -l + +: diff --git a/tests/yflags-conditional.test b/tests/yflags-conditional.test new file mode 100755 index 000000000..8c673b175 --- /dev/null +++ b/tests/yflags-conditional.test @@ -0,0 +1,46 @@ +#! /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 that automake complains about conditionally-defined *_YFLAGS. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_YACC +AM_CONDITIONAL([COND], [:]) +END + +cat > Makefile.am <<'END' +bin_PROGRAMS = foo bar +foo_SOURCES = foo.y +bar_SOURCES = bar.y +if COND +AM_YFLAGS = $(YFLAGS) +bar_YFLAGS = -v +endif COND +END + +: > ylwrap + +$ACLOCAL +AUTOMAKE_fails +grep "Makefile\.am:5:.*AM_YFLAGS.* defined conditionally" stderr +grep "Makefile\.am:6:.*bar_YFLAGS.* defined conditionally" stderr + +: diff --git a/tests/yflags-d-false-positives.test b/tests/yflags-d-false-positives.test new file mode 100755 index 000000000..38ea7639c --- /dev/null +++ b/tests/yflags-d-false-positives.test @@ -0,0 +1,43 @@ +#! /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 for false positives in automake recognition of `-d' in YFLAGS. + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_YACC +END + +$ACLOCAL + +cat > Makefile.am <<'END' +bin_PROGRAMS = zardoz foobar +zardoz_SOURCES = zardoz.y +foobar_SOURCES = foobar.y +# All the "almost -d" substrings ("- d", "-dd", etc.) are meant. +AM_YFLAGS = -xd --d - d --output=d +foobar_YFLAGS = - d $(foovar)-d -dd +END + +$AUTOMAKE -a +$EGREP '(foobar|zardoz)\.h.*:' Makefile.in && Exit 1 +$EGREP '(foobar|zardoz)\.h' Makefile.in | $FGREP -v '$(YLWRAP) ' && Exit 1 + +: diff --git a/tests/yflags-force-override.test b/tests/yflags-force-override.test new file mode 100755 index 000000000..7a3197fcd --- /dev/null +++ b/tests/yflags-force-override.test @@ -0,0 +1,66 @@ +#! /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 that automake can cope with a definition of the $(YFLAGS) variable +# in Makefile.am (even if that is extremely bad practice, because that +# variable is user-reserved). + +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 +foo_SOURCES = foo.y +# Don't do this in a real-life Makefile.am! +YFLAGS = -d -v +END + +cat > foo.y << 'END' +%{ +int yylex () { return 0; } +void yyerror (char *s) { return; } +int main () { return 0; } +%} +%% +foobar : 'f' 'o' 'o' 'b' 'a' 'r' {}; +END + +$ACLOCAL +$AUTOMAKE -a -Wno-gnu + +$EGREP '(foo|YFLAGS)' Makefile.in # for debugging +grep '^foo.h *:' Makefile.in + +$AUTOCONF +./configure + +$MAKE + +test -f foo.c +test -f foo.h +test -f foo.output + +$MAKE distcheck + +: diff --git a/tests/yflags-var-expand.test b/tests/yflags-var-expand.test new file mode 100755 index 000000000..1967be300 --- /dev/null +++ b/tests/yflags-var-expand.test @@ -0,0 +1,63 @@ +#! /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 that automake expand variables when looking for `-d' in YFLAGS; +# for example, the following is supposed to work: +# foo_flags = -d +# AM_YFLAGS = $(foo_flags) + +. ./defs || Exit 1 + +set -e + +cat >> configure.in <<'END' +AC_PROG_CC +AC_PROG_YACC +END + +$ACLOCAL + +cat > Makefile.am <<'END' +bin_PROGRAMS = foo bar +foo_SOURCES = foo.y +bar_SOURCES = bar.y +my_YFLAGS = -x +AM_YFLAGS = $(my_YFLAGS:x=d) +bar_YFLAGS = $(AM_YFLAGS) +END + +$AUTOMAKE -a + +$EGREP '(foo|bar|YFLAGS)' Makefile.in # for debugging +grep '^foo.h *:' Makefile.in +grep '^bar-bar.h *:' Makefile.in + +cat > Makefile.am <<'END' +AUTOMAKE_OPTIONS = -Wno-gnu +bin_PROGRAMS = zardoz +zardoz_SOURCES = parser.y +my_YFLAGS = $(my_YFLAGS_1) +my_YFLAGS += $(my_YFLAGS_2) +my_YFLAGS_2 = -d +YFLAGS = $(my_YFLAGS) +END + +$AUTOMAKE + +$EGREP 'parser|YFLAGS' Makefile.in # for debugging +grep '^parser.h *:' Makefile.in + +: -- 2.47.2