Skip to content

Commit fae46e0

Browse files
committed
examples: beware of portability issue on Windows
Reported by Jannick. https://lists.gnu.org/r/bug-bison/2020-05/msg00040.html https://lists.gnu.org/r/bug-bison/2020-05/msg00066.html * examples/test (diff_opts): Use --strip-trailing-cr if supported, to avoid \n vs. \r\n issues. * examples/c/bistromathic/bistromathic.test: When on MSYS, don't try to check autocompletion.
1 parent d22e60d commit fae46e0

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

examples/c/bistromathic/bistromathic.test

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ echo >perfect '> 0
4141
echo >ok '0'
4242
echo '0' | prog >effective
4343

44-
if diff perfect effective >/dev/null 2>&1; then
44+
echo "checking for readline output"
45+
if diff perfect effective; then
4546
# Alles ist gut.
4647
strip_prompt=false
47-
elif diff ok effective >/dev/null 2>&1; then
48+
elif diff ok effective; then
4849
strip_prompt=true
4950
else
5051
skip "this is not the GNU Readline we expect"
@@ -257,14 +258,22 @@ err: Cleanup: popping nterm input (1.1-4: )' -p
257258
# From now on, the differences between versions of GNU Readline are
258259
# too painful to try to cope with.
259260
if $strip_prompt; then
260-
echo "SKIP: this is not the GNU Readline we expect"
261-
if $exit; then
262-
exit 0
263-
else
264-
exit 1
265-
fi
261+
echo "SKIP: this is not the GNU Readline we expect"
262+
exit $status
266263
fi
267264

265+
# On Windows10/MSYS2 the ^G coming from <tab> completion is not
266+
# emitted the same way
267+
# (https://lists.gnu.org/r/bug-bison/2020-05/msg00076.html).
268+
echo "checking for kernel name"
269+
case `uname -s` in
270+
(MSYS*)
271+
echo "SKIP: this is Windows/MSYS"
272+
exit $status
273+
;;
274+
esac
275+
276+
268277
# Check completion after an operator.
269278
sed -e 's/\\t/ /g' >input <<EOF
270279
(1+\t\t

examples/test

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ cwd=$(pwd)
3434
# See bistromathic.test.
3535
strip_prompt=false
3636

37+
# If diff supports --strip-trailing-cr, use it, to avoid EOL issues
38+
# when testing Java programs on Windows.
39+
echo "checking for diff --strip-trailing-cr"
40+
if diff --strip-trailing-cr "$1" "$1"; then
41+
diff_opts=--strip-trailing-cr
42+
fi
43+
3744
# The exercised program.
3845
abs_medir=$cwd/examples/$medir
3946
if test -x "$abs_medir/$me"; then
@@ -129,7 +136,7 @@ run ()
129136
} >eff
130137

131138
if test $sta_eff -eq $sta_exp; then
132-
if diff eff exp >/dev/null 2>&1; then
139+
if diff $diff_opts eff exp >/dev/null 2>&1; then
133140
echo "$me: PASS: $number"
134141
else
135142
echo "$me: FAIL: $number"
@@ -140,7 +147,7 @@ run ()
140147
echo "$me: effective output:"
141148
sed -e 's/^/ /' eff
142149
echo "$me: diff:"
143-
diff -u exp eff | sed -e 's/^/ /'
150+
diff $diff_opts -u exp eff | sed -e 's/^/ /'
144151
status=1
145152
fi
146153
else

0 commit comments

Comments
 (0)