Yet more tests on Yacc/Lex support, this time explicitly meant to verify the output produced by the codepaths affected by our change.
The new tests are admittedly pretty hackish, but are IMHO necessary. --- * tests/lex10.test: New test script. * tests/lex11.test: Likewise. * tests/yacc12.test: Likewise. * tests/yacc13.test: Likewise. * tests/yl-static-checks.sh: New shell script, used by the new test scripts. * tests/Makefile.am (TESTS, EXTRA_DIST): Updated. (lex10.log, lex11.log, yacc12.log, yacc13.log): Depends from new script `yl-static-checks.sh'. --- ChangeLog | 11 ++ tests/Makefile.am | 10 ++- tests/Makefile.in | 10 ++- tests/lex10.test | 26 ++++ tests/lex11.test | 26 ++++ tests/yacc12.test | 26 ++++ tests/yacc13.test | 26 ++++ tests/yl-static-checks.sh | 333 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 466 insertions(+), 2 deletions(-) create mode 100755 tests/lex10.test create mode 100755 tests/lex11.test create mode 100755 tests/yacc12.test create mode 100755 tests/yacc13.test create mode 100644 tests/yl-static-checks.sh
From 92160c5e78b72dcc303c739a93657c979623091e Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Wed, 19 May 2010 13:11:45 +0200 Subject: [PATCH 5/6] New tests on Lex and Yacc dependencies declarations. * tests/lex10.test: New test script. * tests/lex11.test: Likewise. * tests/yacc12.test: Likewise. * tests/yacc13.test: Likewise. * tests/yl-static-checks.sh: New shell script, used by the new test scripts. * tests/Makefile.am (TESTS, EXTRA_DIST): Updated. (lex10.log, lex11.log, yacc12.log, yacc13.log): Depends from new script `yl-static-checks.sh'. --- ChangeLog | 11 ++ tests/Makefile.am | 10 ++- tests/Makefile.in | 10 ++- tests/lex10.test | 26 ++++ tests/lex11.test | 26 ++++ tests/yacc12.test | 26 ++++ tests/yacc13.test | 26 ++++ tests/yl-static-checks.sh | 333 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 466 insertions(+), 2 deletions(-) create mode 100755 tests/lex10.test create mode 100755 tests/lex11.test create mode 100755 tests/yacc12.test create mode 100755 tests/yacc13.test create mode 100644 tests/yl-static-checks.sh diff --git a/ChangeLog b/ChangeLog index a514481..2c87601 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2010-05-20 Stefano Lattarini <stefano.lattar...@gmail.com> + New tests on Lex and Yacc dependencies declarations. + * tests/lex10.test: New test script. + * tests/lex11.test: Likewise. + * tests/yacc12.test: Likewise. + * tests/yacc13.test: Likewise. + * tests/yl-static-checks.sh: New shell script, used by the new + test scripts. + * tests/Makefile.am (TESTS, EXTRA_DIST): Updated. + (lex10.log, lex11.log, yacc12.log, yacc13.log): Depends from new + script `yl-static-checks.sh'. + automake.in: improve declaration of dependencies in generated Makefile.in files. * automake.in (handle_single_transform): Unconditionally emit diff --git a/tests/Makefile.am b/tests/Makefile.am index 3df93a4..793e041 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -40,6 +40,10 @@ $(parallel_tests): Makefile.am MAINTAINERCLEANFILES = $(parallel_tests) +# The tests lex10.test, lex11.test, yacc12.test and yacc13.test source +# the `yl-static-checks.sh' helper script. +lex10.log lex11.log yacc12.log yacc13.log: yl-static-checks.sh + TESTS = \ aclibobj.test \ aclocal.test \ @@ -407,6 +411,8 @@ lex6.test \ lex7.test \ lex8.test \ lex9.test \ +lex10.test \ +lex11.test \ lexcpp.test \ lexvpath.test \ libexec.test \ @@ -786,11 +792,13 @@ yacc8.test \ yacc9.test \ yacc10.test \ yacc11.test \ +yacc12.test \ +yacc13.test \ yaccpp.test \ yaccvpath.test \ $(parallel_tests) -EXTRA_DIST = ChangeLog-old gen-parallel-tests $(TESTS) +EXTRA_DIST = ChangeLog-old gen-parallel-tests yl-static-checks.sh $(TESTS) # Each test case depends on defs, aclocal, and automake. check_SCRIPTS = defs aclocal-$(APIVERSION) automake-$(APIVERSION) diff --git a/tests/Makefile.in b/tests/Makefile.in index 6ec61a4..48f23e3 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -648,6 +648,8 @@ lex6.test \ lex7.test \ lex8.test \ lex9.test \ +lex10.test \ +lex11.test \ lexcpp.test \ lexvpath.test \ libexec.test \ @@ -1027,11 +1029,13 @@ yacc8.test \ yacc9.test \ yacc10.test \ yacc11.test \ +yacc12.test \ +yacc13.test \ yaccpp.test \ yaccvpath.test \ $(parallel_tests) -EXTRA_DIST = ChangeLog-old gen-parallel-tests $(TESTS) +EXTRA_DIST = ChangeLog-old gen-parallel-tests yl-static-checks.sh $(TESTS) # Each test case depends on defs, aclocal, and automake. check_SCRIPTS = defs aclocal-$(APIVERSION) automake-$(APIVERSION) @@ -1399,6 +1403,10 @@ $(parallel_tests): Makefile.am } > $...@-t $(AM_V_at)chmod a+rx $...@-t && mv -f $...@-t $@ +# The tests lex10.test, lex11.test, yacc12.test and yacc13.test source +# the `yl-static-checks.sh' helper script. +lex10.log lex11.log yacc12.log yacc13.log: yl-static-checks.sh + clean-local: clean-local-check .PHONY: clean-local-check clean-local-check: diff --git a/tests/lex10.test b/tests/lex10.test new file mode 100755 index 0000000..5220f6f --- /dev/null +++ b/tests/lex10.test @@ -0,0 +1,26 @@ +#! /bin/sh +# Copyright (C) 2010 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/>. + +# Static checks on the rules generated by Automake Lex subsystem (done +# by grepping Makefile.in). In particular, look out for redundant or +# extraneous rules. + +. ./defs || Exit 1 + +lang=lex +subdir_objects=no + +. "$testsrcdir"/yl-static-checks.sh diff --git a/tests/lex11.test b/tests/lex11.test new file mode 100755 index 0000000..bb7c413 --- /dev/null +++ b/tests/lex11.test @@ -0,0 +1,26 @@ +#! /bin/sh +# Copyright (C) 2010 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/>. + +# Static checks on the rules generated by Automake Lex subsystem (done +# by grepping Makefile.in). In particular, look out for redundant or +# extraneous rules. + +. ./defs || Exit 1 + +lang=lex +subdir_objects=yes + +. "$testsrcdir"/yl-static-checks.sh diff --git a/tests/yacc12.test b/tests/yacc12.test new file mode 100755 index 0000000..189bc69 --- /dev/null +++ b/tests/yacc12.test @@ -0,0 +1,26 @@ +#! /bin/sh +# Copyright (C) 2010 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/>. + +# Static checks on the rules generated by Automake Yacc subsystem (done +# by grepping Makefile.in). In particular, look out for redundant or +# extraneous rules. + +. ./defs || Exit 1 + +lang=yacc +subdir_objects=no + +. "$testsrcdir"/yl-static-checks.sh diff --git a/tests/yacc13.test b/tests/yacc13.test new file mode 100755 index 0000000..d28c653 --- /dev/null +++ b/tests/yacc13.test @@ -0,0 +1,26 @@ +#! /bin/sh +# Copyright (C) 2010 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/>. + +# Static checks on the rules generated by Automake Lex subsystem (done +# by grepping Makefile.in). In particular, look out for redundant or +# extraneous rules. + +. ./defs || Exit 1 + +lang=yacc +subdir_objects=yes + +. "$testsrcdir"/yl-static-checks.sh diff --git a/tests/yl-static-checks.sh b/tests/yl-static-checks.sh new file mode 100644 index 0000000..7a4d2ae --- /dev/null +++ b/tests/yl-static-checks.sh @@ -0,0 +1,333 @@ +#! /bin/sh +# Copyright (C) 2010 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/>. + +# Helper file sourced by test script doing static checks on the rules +# generated by Automake Lex/Yacc subsystems. +# These static checks are done by grepping Makefile.in, and look out +# for redundant or extraneous rules. +# This file must be sourced after `./defs' has been sourced. + + +## Sanity checks and related initializations. + +case $subdir_objects in + no) + prefix='';; + yes) + prefix='x/';; + *) + echo "$me: invalid value for \$subdir_objects: '$subdir_objects'" >&2 + Exit 99;; +esac + +case $lang in + lex) + extra_ac_macros=AC_PROG_LEX + flagsname=LFLAGS + srcext=l + ;; + yacc) + extra_ac_macros=AC_PROG_YACC + flagsname=YFLAGS + srcext=y + ;; + *) + echo "$me: invalid value for \$lang: '$lang'" >&2 + Exit 99 + ;; +esac + + +## Helper subroutines & variables. + +lc='abcdefghijklmnopqrstuvwxyz' +uc='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +dg='0123456789' +tab=' ' + +# Rustic marker for the beginning of a word. +wstart="(^|[^${uc}${lc}${dg}_.-])" + +quote_for_egrep() +{ + echo "$1" | sed -e 's/[*?().$|]/\\&/g' +} + +get_trg_and_dep() +{ + if test x"$subdir_objects" = x"yes"; then + trg=`quote_for_egrep "$prefix$1"` + dep=`quote_for_egrep "$prefix$2"` + else + trg=`quote_for_egrep "$1"` + dep=`quote_for_egrep "$2"` + fi +} + +depends_one_time() +{ + case $#,$1 in + 3,--with-rules) with_rules=:;; + 3,--without-rules) with_rules=false;; + *) echo "depends_one_time: Usage error" >&2; Exit 99;; + esac + get_trg_and_dep "$2" "$3" + $EGREP "^$trg: *$dep " M0 || Exit 1 + test 1 = `$EGREP -c "^$trg *:.*$dep " M0` || Exit 1 + if $with_rules; then + $EGREP "^$trg: *$dep " Mr || Exit 1 + else + $EGREP "^$trg: *$dep " Mr && Exit 1 + fi + : +} + +does_not_depend() +{ + test $# -eq 2 || { echo "does_not_depend: Usage error" >&2; Exit 99; } + get_trg_and_dep "$1" "$2" + $EGREP "^$trg: *$dep " M0 && Exit 1 + : +} + +no_plain_object() +{ + x=`quote_for_egrep "$1"` + $EGREP "$x"'\.(o|.obj|\$\(OBJEXT\)) ' Mx && Exit 1 + rm -f Mx +} + +no_libtool_object() +{ + x=`quote_for_egrep "$1"` + $EGREP "$x\\.lo " M0 && Exit 1 + : +} + +is_obj_listed() +{ + case $#,$1 in + 3,--plain) ltobj=false;; + 3,--libtool) ltobj=:;; + *) echo "is_obj_listed: Usage error" >&2; Exit 99;; + esac + if test x"$subdir_objects" = x"yes"; then + x=`quote_for_egrep "$prefix$2"` + else + x=`quote_for_egrep "$2"` + fi + y=`quote_for_egrep "$3"` + if $ltobj; then + $EGREP "${y}_la_OBJECTS *= *$x\\.lo " M0 || Exit 1 + else + $EGREP "${y}_OBJECTS *= *$x"'\.\$\(OBJEXT\) ' M0 || Exit 1 + fi + : +} + + +## Data files. + +cat >> configure.in <<END +AC_PROG_CC +AM_PROG_CC_C_O +AC_SUBST([LIBTOOL], [:]) dnl fake libtool +$extra_ac_macros +END + +cat > Makefile.am <<END +bin_PROGRAMS = foo bar baz qux +lib_LTLIBRARIES = libfoo.la libbar.la libbaz.la libqux.la + +foo_SOURCES = ${prefix}foo.$srcext +bar_SOURCES = ${prefix}bar.$srcext +baz_SOURCES = ${prefix}baz.$srcext +qux_SOURCES = ${prefix}qux.$srcext + +bar_$flagsname = \$(AM_$flagsname) + +baz_CFLAGS = \$(AM_CFLAGS) + +qux_$flagsname = \$(AM_$flagsname) +qux_CFLAGS = \$(AM_CFLAGS) + +libfoo_la_SOURCES = ${prefix}FOO.$srcext +libbar_la_SOURCES = ${prefix}BAR.$srcext +libbaz_la_SOURCES = ${prefix}BAZ.$srcext +libqux_la_SOURCES = ${prefix}QUX.$srcext + +libbar_la_$flagsname = \$(AM_$flagsname) + +libbaz_la_CFLAGS = \$(AM_CFLAGS) + +libqux_la_$flagsname = \$(AM_$flagsname) +libqux_la_CFLAGS = \$(AM_CFLAGS) +END + +if test x"$subdir_objects" = x"yes"; then + echo 'AUTOMAKE_OPTIONS = subdir-objects' >>Makefile.am +fi + +: > ltmain.sh + + +## Go with tests. + +$ACLOCAL +$AUTOMAKE -a + +# These transformations will simplify the grepping. + +# Make every non-continued line ends with a space, and turn every +# non-line-starting tabulation character into a simple whitespace, +# and squash repeated whitespaces togheter. +sed -e '/.*[^\\]$/s/ *$/ /' \ + -e "/^[^$tab]/s/$tab/ /g" \ + -e "s/ */ /g" \ + <Makefile.in >M0 + +# The comments in automake say that if we have a libtool object, then +# we must remove also the ordinary `.o' object. This is done in the +# `mostlyclean-compile' target, so we might want ignore it (and its +# rules) in some situations. +$PERL -npe ' + if (s/^mostlyclean-compile:\s*$/\t/) { + $_ = <> while defined($_) && !/^$/ && !/^[^\t]/; + }' <M0 >Mx + +# Only keep targets/dependencies wich have associated rules. +$PERL -w -e ' + use strict; use warnings FATAL => "all"; + my $am_cond_rx = qr/@\w+_(?:TRUE|FALSE)@/; + my @lines = <STDIN>; + while ($_ = shift @lines) { + # Deal with continued lines. + $_ .= shift(@lines) while (s/(\s*)\\\n\z/$1/); + # Strip off trailing newline. + chomp; + # Ignore all variable assingnments. + next if /^\s*\w+\s*=/; + # Ignore lines which are not target declarations. + next unless /^\S.*:/; + # Accept both formats + # target: prereq; rules + # and + # target: prereq + # rules + if (/([^;]*);/) { + $_ = $1; + } else { + my $t = shift @lines; + # Account for automake conditionals too. + if (not defined $t or $t !~ /^(?:$am_cond_rx)?\t/) { + unshift @lines, $t; + next; + } + } + # If we are here, the target has an associated rule. Normalize it + # and its dependencies, and print them. + s/\s+/ /g; + s/ *$/ \n/; + print; + } +' < Makefile.in >Mr + +# We won't show `Makefile.in', `M0' and `Mx', as they are too long. +# The following can be useful for debugging, though +cat Mr +if diff M0 Mx; then + echo "$me: INFO: M0 and Mx are equals" +else + echo "$me: INFO: M0 and Mx differs" +fi + +# Since we defined neither `foo_LFLAGS' nor `foo_CFLAGS', the foo object +# is not expect to go through any renaming, nor to have any explicit +# rules w.r.t. either the `.l => .c' nor the `.c => .o' transformations. +# Similarly for libfoo_la (the details change, but you should have got +# the gist). +is_obj_listed --plain foo foo # sanity check +is_obj_listed --libtool FOO libfoo # likewise +depends_one_time --without-rules foo.c foo.$srcext +depends_one_time --without-rules 'foo.$(OBJEXT)' foo.c +depends_one_time --without-rules FOO.c FOO.$srcext +depends_one_time --without-rules FOO.lo FOO.c +does_not_depend foo.o foo.c +does_not_depend foo.obj foo.c +no_libtool_object foo +no_plain_object FOO +# no name tranformation expected +$EGREP -i 'foo-|-foo' M0 && Exit 1 + +# Since we defined `bar_LFLAGS' but not `bar_CFLAGS', the bar object +# is expect to go through just one renaming: bar.y => bar-bar.c, and +# to have explicit rules for the `.y => .c' transformation only. +# Similarly for libbar_la (the details change, but you should have got +# the gist). +is_obj_listed --plain bar-bar bar # sanity check +is_obj_listed --libtool libbar_la-BAR libbar # likewise +depends_one_time --with-rules bar-bar.c bar.$srcext +depends_one_time --without-rules 'bar-bar.$(OBJEXT)' bar-bar.c +depends_one_time --with-rules libbar_la-BAR.c BAR.$srcext +depends_one_time --without-rules libbar_la-BAR.lo libbar_la-BAR.c +does_not_depend bar-bar.o bar-bar.c +does_not_depend bar-bar.obj bar-bar.c +no_plain_object BAR +no_libtool_object bar +# Name transformation expected for C (and indirectly reflected on +# objects files). +$EGREP -i "${wstart}"'bar\.(c|o|obj|lo|\$\(OBJEXT\)) ' M0 && Exit 1 + +# Since we defined `baz_CFLAGS' but not `baz_LFLAGS', the baz object +# is expect to go through just one renaming: baz.c => baz-baz.$(OBJEXT), +# and to have explicit rules for the `.c => .o' transformation only. +# Similarly for libfoo_la (the details change, but you should have got +# the gist). +is_obj_listed --plain baz-baz baz # sanity check +is_obj_listed --libtool libbaz_la-BAZ libbaz # likewise +depends_one_time --without-rules baz.c baz.$srcext +depends_one_time --with-rules baz-baz.o baz.c +depends_one_time --with-rules baz-baz.obj baz.c +does_not_depend 'baz-baz.$(OBJEXT)' baz.c +depends_one_time --without-rules BAZ.c BAZ.$srcext +depends_one_time --with-rules libbaz_la-BAZ.lo BAZ.c +no_plain_object BAZ +no_libtool_object baz +# Name transformation expected for objects only. +$EGREP -i "${wstart}"'baz\.(o|obj|lo|\$\(OBJEXT\)) ' M0 && Exit 1 + +# Since we defined both `qux_CFLAGS' and `qux_LFLAGS', the qux object +# is expect to go through two renaming: `qux.y => qux-qux.c' and +# `qux-qux.c => qux-qux.$(OBJEXT)'; it's also expected to have explicit +# rules for both the `.y => .c' and the `.c => .o' transformations. +# Similarly for libqux_la (the details change, but you should have got +# the gist). +is_obj_listed --plain qux-qux-qux qux # sanity check +is_obj_listed --libtool libqux_la-libqux_la-QUX libqux # likewise +depends_one_time --with-rules qux-qux.c qux.$srcext +depends_one_time --with-rules qux-qux-qux.o qux-qux.c +depends_one_time --with-rules qux-qux-qux.obj qux-qux.c +does_not_depend 'qux-qux-qux.$(OBJEXT)' qux-qux.c +depends_one_time --with-rules libqux_la-QUX.c QUX.$srcext +depends_one_time --with-rules libqux_la-libqux_la-QUX.lo libqux_la-QUX.c +no_plain_object QUX +no_libtool_object baz +# Name transformation expected fot both C and object files. +$EGREP -i "${wstart}"'qux\.(c|o|obj|lo|\$\(OBJEXT\)) ' M0 && Exit 1 +$EGREP -i "${wstart}"'qux-qux\.(o|obj|lo|\$\(OBJEXT\)) ' M0 && Exit 1 +$EGREP -i "${wstart}"'libqux_la\.(o|obj|lo|\$\(OBJEXT\)) ' M0 && Exit 1 + +: -- 1.6.5