X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/fc7ce9970f2972443c1a031c91ffef2dfdf28651..7fb72c6e53f25f2d0b10fc9e0b412b8c7cde9101:/tests/local.at?ds=sidebyside diff --git a/tests/local.at b/tests/local.at index f08185a5..65e528f9 100644 --- a/tests/local.at +++ b/tests/local.at @@ -2,7 +2,7 @@ # Macros for the GNU Bison Test suite. -# Copyright (C) 2003-2011 Free Software Foundation, Inc. +# Copyright (C) 2003-2012 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,33 @@ printf "$count\n";' $1], [0], [$3 ])]) +# AT_SAVE_SPECIAL_FILES / AT_RESTORE_SPECIAL_FILES +# ------------------------------------------------ +# Don't interfere with caller's files. +m4_divert_text([PREPARE_TESTS], +[at_save_special_files () +{ + for at_save_file in stderr experr expout + do + test ! -f $at_save_file || mv $at_save_file at-bison-check-$at_save_file.bak + done +} + +at_restore_special_files () +{ + for at_save_file in stderr experr expout + do + test ! -f at-bison-check-$at_save_file.bak || + mv at-bison-check-$at_save_file.bak $at_save_file + done +} +]) + +m4_define([AT_SAVE_SPECIAL_FILES], [at_save_special_files]) +m4_define([AT_RESTORE_SPECIAL_FILES], [at_restore_special_files]) + + + ## ------------------------------- ## ## Macros decoding Bison options. ## ## ------------------------------- ## @@ -279,13 +306,11 @@ m4_define([AT_BISON_CHECK_NO_XML], [AT_QUELL_VALGRIND ])[[bison ]]$@) m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], m4_quote(m4_if(m4_quote($2), [], [0], [$2])), [0], [[ - # POSIXLY_CORRECT=1 causes bison to complain if options are added - # after the grammar file name, so skip these checks in that case. - if test x"$POSIXLY_CORRECT" != x1; then - # Don't interfere with caller's files. - if test -f stderr; then mv stderr at-bison-check-stderr.bak; fi - if test -f experr; then mv experr at-bison-check-experr.bak; fi - if test -f expout; then mv expout at-bison-check-expout.bak; fi + # Defining POSIXLY_CORRECT causes bison to complain if options + # are added after the grammar file name, so skip these checks + # in that case. + if test -z "${POSIXLY_CORRECT+set}"; then + ]AT_SAVE_SPECIAL_FILES[ # To avoid expanding it repeatedly, store specified stdout. ]AT_DATA([expout], [$3])[ @@ -297,10 +322,15 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # Build expected stderr up to and including the "warnings being # treated as errors" message. ]AT_DATA([[at-bison-check-warnings]], [$4])[ - at_bison_check_first="` \ - sed -n '/: warning: /=' at-bison-check-warnings \ - | sed -n 1p \ - `" + at_bison_check_first=`sed -n \ + '/: warning: /{=;q;}' at-bison-check-warnings` + : ${at_bison_check_first:=1} + at_bison_check_first_tmp=`sed -n \ + '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings` + : ${at_bison_check_first_tmp:=1} + if test $at_bison_check_first_tmp -lt $at_bison_check_first; then + at_bison_check_first=$at_bison_check_first_tmp + fi if test $at_bison_check_first -gt 1; then sed -n "1,`expr $at_bison_check_first - 1`"p \ at-bison-check-warnings > experr @@ -311,11 +341,9 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # complaints cause bison to exit early. Thus, with -Werror, bison # does not necessarily report all warnings that it does without # -Werror, but it at least reports one. - at_bison_check_last="`sed -n '$=' stderr`" - if test x"$at_bison_check_last" = x; then - at_bison_check_last=1 - fi - at_bison_check_last="`expr $at_bison_check_last - 1`" + at_bison_check_last=`sed -n '$=' stderr` + : ${at_bison_check_last:=1} + at_bison_check_last=`expr $at_bison_check_last - 1` sed -n "$at_bison_check_first,$at_bison_check_last"p \ at-bison-check-warnings >> experr ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \ @@ -330,20 +358,11 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # -Werror doesn't change the exit status when -Wnone or # --warnings=none is specified. ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ -Wnone -Werror]], - [[0]], [expout], [ignore])[ + [[0]], [expout])[ ]AT_CHECK(AT_QUELL_VALGRIND[[ bison ]$1[ --warnings=none \ - -Werror]], [[0]], [expout], [ignore])[ + -Werror]], [[0]], [expout])[ - # Restore caller's files. - if test -f at-bison-check-expout.bak; then - mv at-bison-check-expout.bak expout - fi - if test -f at-bison-check-experr.bak; then - mv at-bison-check-experr.bak experr - fi - if test -f at-bison-check-stderr.bak; then - mv at-bison-check-stderr.bak stderr - fi + ]AT_RESTORE_SPECIAL_FILES[ fi ]]) ]) @@ -354,8 +373,9 @@ m4_if(m4_bregexp([$4], [: warning: ]), [-1], [], # defined. It doesn't make sense to invoke this macro if Bison is expected to # have a non-zero exit status. m4_define([AT_BISON_CHECK_XML], -[[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then - mkdir xml-tests] +[[if test x"$BISON_TEST_XML" = x1 && test x"$XSLTPROC" != x""; then] + AT_SAVE_SPECIAL_FILES + [mkdir xml-tests] m4_pushdef([AT_BISON_ARGS], [m4_bpatsubsts([[$1]], [--report(-file)?=[^][ ]*], [], @@ -377,8 +397,9 @@ m4_define([AT_BISON_CHECK_XML], AT_CHECK([[$XSLTPROC \ `]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2dot.xsl \ xml-tests/test.xml]], [[0]], [expout]) - [rm -rf xml-tests expout -fi]]) + [rm -rf xml-tests expout] + AT_RESTORE_SPECIAL_FILES +[fi]]) # AT_QUELL_VALGRIND # ----------------- @@ -457,17 +478,26 @@ m4_define([AT_FULL_COMPILE], [ ## Running a generated parser. ## ## ---------------------------- ## + # AT_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE]) # ------------------------------------------------------------ # So that we can run `./testsuite PREPARSER='valgrind -q' for instance. +# +# Get rid of spurious messages when compiled with --coverage: +# +profiling:/[...]/lib/fprintf.gcda:Merge mismatch for summaries m4_define([AT_PARSER_CHECK], -[AT_CHECK([$5 $PREPARSER $1], [$2], [$3], [$4])]) +[AT_CHECK([$5 $PREPARSER $1], [$2], [$3], [stderr]) +AT_CHECK([sed >&2 -e '/^profiling:.*:Merge mismatch for summaries/d' stderr], + [0], [], [$4]) +]) + # AT_JAVA_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE]) # ----------------------------------------------------------------- m4_define([AT_JAVA_PARSER_CHECK], [AT_CHECK([$5[ $SHELL ../../../javaexec.sh ]$1], [$2], [$3], [$4])]) + # AT_TEST_TABLES_AND_PARSE(TITLE, COND-VALUE, TEST-SPEC, # DECLS, GRAMMAR, INPUT, # BISON-STDERR, TABLES-OR-LAST-STATE, @@ -606,6 +636,17 @@ m4_if(m4_index(m4_quote($3), [last-state]), -1, $9 +# Canonical LR generates very large tables, resulting in very long +# files with #line directives that may overflow what the standards +# (C90 and C++98) guarantee: 32767. In that case, GCC's -pedantic +# will issue an error. +# +# There is no "" around `wc` since some indent the result. +m4_bmatch([$4], [%define lr.type canonical-lr], +[if test 32767 -lt `wc -l < input.c`; then + CFLAGS=`echo " $CFLAGS " | sed -e 's/ -pedantic //'` + CXXFLAGS=`echo " $CXXFLAGS " | sed -e 's/ -pedantic //'` +fi]) AT_COMPILE([[input]]) AT_PARSER_CHECK([[./input]], @@ -625,4 +666,15 @@ m4_popdef([AT_COND_CASE])]) AT_INIT +# Cannot assign CC and CFLAGS here, since atlocal is loaded after +# options are processed, so we don't know the value of CXX and +# CXXFLAGS yet. +# +# Note that it also means that command line values for CXX and +# CXXFLAGS will not be propagated to CC and CFLAGS. +AT_ARG_OPTION([compile-c-with-cxx], + [compile C parsers with the C++ compiler]) + +AT_COLOR_TESTS + AT_TESTED([bison])