add support for --html

* bootstrap.conf: We need the "execute" module.
* src/files.h, src/files.c (spec_html_file, html_flag): New.
* src/getargs.h, src/getargs.c (--html): New.
* src/print-xml.h, src/print-xml.c (print_html): New.
* src/main.c: Use them.
* tests/output.at, tests/report.at: Check --html.
This commit is contained in:
Akim Demaille
2020-09-06 16:24:18 +02:00
parent f5d4b64909
commit 0711dca9d9
17 changed files with 116 additions and 27 deletions

View File

@@ -33,7 +33,7 @@ m4_if(m4_index([$1], [Counterexample]), [-1], [], [AT_KEYWORDS([cex])])
# We need UTF-8 support for correct screen-width computation of UTF-8
# characters. Skip the test if not available.
locale=`locale -a | $EGREP '^en_US\.(UTF-8|utf8)$' | sed 1q`
AT_SKIP_IF([test x == x"$locale"])
AT_SKIP_IF([[test x = x"$locale"]])
m4_ifval([$6],
[AT_SKIP_IF([$6])])

View File

@@ -131,7 +131,7 @@ maintainer-check-posix: $(RUN_TESTSUITE_deps)
VALGRIND_OPTS = --leak-check=full --show-reachable=yes --gen-suppressions=all \
$(VALGRIND_OPTS_SUPPRESSION)
maintainer-check-valgrind: $(RUN_TESTSUITE_deps)
test 'x$(VALGRIND)' == x || \
test 'x$(VALGRIND)' = x || \
$(RUN_TESTSUITE) \
PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q' \
VALGRIND_OPTS="$(VALGRIND_OPTS)"

View File

@@ -36,6 +36,8 @@ m4_define([AT_CHECK_FILES],
# -----------------------------------------------------------------
m4_define([AT_CHECK_OUTPUT],
[AT_SETUP([[Output files: ]$2 $3])[
]m4_bmatch([$3], [--html],
[AT_SKIP_IF([[test x"$XSLTPROC" = x]])])[
]$7[
for file in ]$1 $4[; do
case $file in
@@ -90,6 +92,11 @@ AT_CHECK_OUTPUT([foo.y], [%define api.header.include {"./foo.h"}], [-dv -y],
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
[foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [--fixed-output-files -dv -g --html],
[y.dot y.html y.output y.tab.c y.tab.h y.xml])
AT_CHECK_OUTPUT([foo.y], [], [-Hfoo.header -v -gfoo.gv --html=foo.html],
[foo.gv foo.header foo.html foo.output foo.tab.c foo.xml])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml --fixed-output-files],
[y.dot y.output y.tab.c y.tab.h y.xml])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g --xml -y],

View File

@@ -59,7 +59,8 @@ exp:
| "number" { std::swap ($$, $1); };
]])
AT_BISON_CHECK([-o input.cc -v --graph=input.gv --xml input.yy])
AT_SKIP_IF([[test x"$XSLTPROC" = x]])
AT_BISON_CHECK([-o input.cc -v --graph=input.gv --html --xml input.yy])
# Check the contents of the report.
AT_CHECK([cat input.output], [],
@@ -304,7 +305,8 @@ State 19
# Now generate verbose reports.
AT_BISON_CHECK([-o input.cc -rall --graph=input.gv --xml input.yy])
AT_SKIP_IF([[test x"$XSLTPROC" = x]])
AT_BISON_CHECK([-o input.cc -rall --graph=input.gv --html --xml input.yy])
# Check the contents of the report.
AT_CHECK([cat input.output], [],
@@ -1138,14 +1140,7 @@ AT_CHECK([[sed -e 's/bison-xml-report version="[^"]*"/bison-xml-report version="
]])
# Check HTML output.
if test x"$XSLTPROC" != x""; then
AT_CHECK([[$XSLTPROC \
`]]AT_SET_ENV[[ bison --print-datadir`/xslt/xml2xhtml.xsl \
input.xml | \
sed -e 's/GNU Bison [0-9][-.0-9a-z]*/GNU Bison VERSION/' \
>input.html]])
AT_CHECK([cat input.html], [],
AT_CHECK([[sed -e 's/GNU Bison [0-9][-.0-9a-z]*/GNU Bison VERSION/g' input.html]], [],
[[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:bison="http://www.gnu.org/software/bison/">
@@ -1503,7 +1498,6 @@ if test x"$XSLTPROC" != x""; then
permitted in any medium, provided this notice is preserved.</div></body>
</html>
]])
fi
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
@@ -1520,7 +1514,9 @@ AT_KEYWORDS([cex report])
# We need UTF-8 support for correct screen-width computation of UTF-8
# characters. Skip the test if not available.
locale=`locale -a | $EGREP '^en_US\.(UTF-8|utf8)$' | sed 1q`
AT_SKIP_IF([test x == x"$locale"])
AT_SKIP_IF([[test x = x"$locale"]])
AT_SKIP_IF([[test x"$XSLTPROC" = x]])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y],
@@ -1534,7 +1530,7 @@ exp
| "Ñùṃéℝô"
]])
AT_CHECK([LC_ALL="$locale" bison -fno-caret -o input.cc -rall -Wcex --graph=input.gv --xml input.y], [], [],
AT_CHECK([LC_ALL="$locale" bison -fno-caret -o input.cc -rall -Wcex --graph=input.gv --html --xml input.y], [], [],
[[input.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr]
input.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr]
input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples]
@@ -2155,15 +2151,8 @@ AT_CHECK([[sed -e 's/bison-xml-report version="[^"]*"/bison-xml-report version="
</bison-xml-report>
]])
# Check HTML output.
if test x"$XSLTPROC" != x""; then
AT_CHECK([[$XSLTPROC \
`]]AT_SET_ENV[[ bison --print-datadir`/xslt/xml2xhtml.xsl \
input.xml | \
sed -e 's/GNU Bison [0-9][-.0-9a-z]*/GNU Bison VERSION/' \
>input.html]])
AT_CHECK([cat input.html], [],
AT_CHECK([[sed -e 's/GNU Bison [0-9][-.0-9a-z]*/GNU Bison VERSION/g' input.html]], [],
[[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:bison="http://www.gnu.org/software/bison/">
@@ -2391,7 +2380,6 @@ if test x"$XSLTPROC" != x""; then
permitted in any medium, provided this notice is preserved.</div></body>
</html>
]])
fi
AT_BISON_OPTION_POPDEFS
AT_CLEANUP