From 967a59d2c08a33f24708450561e2f8010b604523 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 21 Feb 2019 06:39:13 +0100 Subject: [PATCH] tests: factor the execution of Java parsers * tests/local.at (AT_MAIN_DEFINE(java)): Exit failure on failure. (AT_PARSER_CHECK): If in Java, run AT_JAVA_PARSER_CHECK. * tests/conflicts.at (AT_CONSISTENT_ERRORS_CHECK): Simplify. --- tests/conflicts.at | 8 ++------ tests/local.at | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/conflicts.at b/tests/conflicts.at index 10aa0758..430a8271 100644 --- a/tests/conflicts.at +++ b/tests/conflicts.at @@ -461,14 +461,10 @@ m4_pushdef([AT_EXPECTING], [m4_if($5, [ab], [[, expecting 'a' or 'b']], $5, [a], [[, expecting 'a']], $5, [b], [[, expecting 'b']])]) -AT_JAVA_IF([AT_JAVA_PARSER_CHECK([[input]], [[0]], +AT_PARSER_CHECK([[input]], [[1]], [[]], [[syntax error, unexpected ]$4[]AT_EXPECTING[ -]])], - [AT_PARSER_CHECK([[input]], [[1]], -[[]], -[[syntax error, unexpected ]$4[]AT_EXPECTING[ -]])]) +]]) m4_popdef([AT_EXPECTING]) AT_BISON_OPTION_POPDEFS diff --git a/tests/local.at b/tests/local.at index bdd1d158..602bb577 100644 --- a/tests/local.at +++ b/tests/local.at @@ -727,7 +727,7 @@ m4_define([AT_MAIN_DEFINE(java)], public static void main (String args[]) throws IOException { YYParser p = new YYParser (); - p.parse (); + System.exit (p.parse () ? 0 : 1); } }]]) @@ -1020,7 +1020,7 @@ AT_COMPILE([c-only.o], [c-only.c]) AT_COMPILE_CXX([cxx-only.o], [cxx-only.cc]) AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS $LDFLAGS c-only.o cxx-only.o -o c-and-cxx || exit 77], [0], [ignore], [ignore]) -AT_PARSER_CHECK([c-and-cxx]) +AT_C_PARSER_CHECK([c-and-cxx]) ]) @@ -1104,13 +1104,13 @@ AT_CHECK([@&t@./exception || exit 77], [0], [], [ignore]) ## ---------------------------- ## -# AT_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE]) -# ------------------------------------------------------------ +# AT_C_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], +m4_define([AT_C_PARSER_CHECK], [AT_CHECK([$5 $PREPARSER ./$1], [$2], [$3], [stderr]) AT_CHECK([sed >&2 -e '/^profiling:.*:Merge mismatch for summaries/d' stderr], [0], [], [$4]) @@ -1123,6 +1123,17 @@ m4_define([AT_JAVA_PARSER_CHECK], [AT_CHECK([$5[ $SHELL ../../../javaexec.sh ]$1], [$2], [$3], [$4])]) +# AT_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR, [PRE]) +# ------------------------------------------------------------ +# If we know we are in Java (via AT_BISON_OPTION_PUSHDEFS/POPDEFS), +# run AT_JAVA_PARSER_CHECK, otherwise AT_C_PARSER_CHECK. +m4_define([AT_PARSER_CHECK], +[m4_ifdef([AT_JAVA_IF], + [AT_JAVA_IF([AT_JAVA_PARSER_CHECK($@)], + [AT_C_PARSER_CHECK($@)])], + [AT_C_PARSER_CHECK($@)])]) + + # AT_TEST_TABLES_AND_PARSE(TITLE, COND-VALUE, TEST-SPEC, # DECLS, GRAMMAR, INPUT, # BISON-STDERR, TABLES-OR-LAST-STATE,