mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
tests: beware of portability issues with diff -u
AIX 7.1 supports diff -u, but its output does not match the expected one. Reported by Bruno Haible. https://lists.gnu.org/r/bug-bison/2020-05/msg00049.html * tests/atlocal.in (DIFF_U_WORKS): New. * tests/local.at (AT_DIFF_U_CHECK): New. * tests/existing.at (_AT_TEST_EXISTING_GRAMMAR): Use AT_DIFF_U_CHECK.
This commit is contained in:
@@ -144,3 +144,44 @@ export LC_CTYPE
|
|||||||
|
|
||||||
# Empty if no xsltproc was found
|
# Empty if no xsltproc was found
|
||||||
: ${XSLTPROC='@XSLTPROC@'}
|
: ${XSLTPROC='@XSLTPROC@'}
|
||||||
|
|
||||||
|
|
||||||
|
# Some tests expect a precise diff format. See AT_DIFF_U_CHECK.
|
||||||
|
# See https://lists.gnu.org/r/bug-bison/2020-05/msg00049.html.
|
||||||
|
cat >conftest.1 <<EOF
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >conftest.2 <<EOF
|
||||||
|
1
|
||||||
|
22
|
||||||
|
3
|
||||||
|
4
|
||||||
|
55
|
||||||
|
6
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat >conftest.expected <<EOF
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
1
|
||||||
|
-2
|
||||||
|
+22
|
||||||
|
3
|
||||||
|
4
|
||||||
|
-5
|
||||||
|
+55
|
||||||
|
6
|
||||||
|
EOF
|
||||||
|
|
||||||
|
diff -u conftest.1 conftest.2 2>/dev/null | sed -n '/^@@/,$p' | sed 's/^ $//' >conftest.diff
|
||||||
|
if diff conftest.expected conftest.diff >/dev/null; then
|
||||||
|
DIFF_U_WORKS=true
|
||||||
|
else
|
||||||
|
DIFF_U_WORKS=false
|
||||||
|
fi
|
||||||
|
rm conftest.*
|
||||||
|
|||||||
@@ -35,14 +35,9 @@ dnl time comes, just use sed to drop the line numbers. For now, as LR(1)
|
|||||||
dnl support is rapidly evolving, let's keep that information to be careful.
|
dnl support is rapidly evolving, let's keep that information to be careful.
|
||||||
dnl However, we don't do diffs for canonical LR(1) because the diff is huge.
|
dnl However, we don't do diffs for canonical LR(1) because the diff is huge.
|
||||||
m4_pushdef([AT_LALR1_DIFF_CHECK],
|
m4_pushdef([AT_LALR1_DIFF_CHECK],
|
||||||
[dnl We need diff -u, which is not portable.
|
[AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
|
||||||
AT_CHECK([diff -u /dev/null /dev/null || exit 77], [0], [ignore])
|
|
||||||
|
|
||||||
AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
|
|
||||||
AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore])
|
AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore])
|
||||||
AT_CHECK([[diff -u input-lalr.output input.output \
|
AT_DIFF_U_CHECK([[input-lalr.output input.output]], [$1])])
|
||||||
| sed -n '/^@@/,$p' | sed 's/^ $//']],
|
|
||||||
[[0]], [$1])])
|
|
||||||
|
|
||||||
AT_TEST_TABLES_AND_PARSE([$2[: LALR(1)]], [[LALR]], [[last-state]],
|
AT_TEST_TABLES_AND_PARSE([$2[: LALR(1)]], [[LALR]], [[last-state]],
|
||||||
[[%define lr.type lalr
|
[[%define lr.type lalr
|
||||||
|
|||||||
@@ -83,6 +83,16 @@ set x `LC_ALL=C ls -l '$1'` &&
|
|||||||
## ------------- ##
|
## ------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# AT_DIFF_U_CHECK(DIFF-ARGS, EXPECTED-DIFF)
|
||||||
|
# -----------------------------------------
|
||||||
|
# If diff -u works as we expect, use it, with headers stripped.
|
||||||
|
m4_define([AT_DIFF_U_CHECK],
|
||||||
|
[if $DIFF_U_WORKS; then
|
||||||
|
AT_CHECK([diff -u $1 | sed -n '/^@@/,$p' | sed 's/^ $//'], [0], [$2])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
# AT_PERL_CHECK(PERL-ARGS, ...)
|
# AT_PERL_CHECK(PERL-ARGS, ...)
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# If Perl is available, run this test.
|
# If Perl is available, run this test.
|
||||||
|
|||||||
Reference in New Issue
Block a user