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.
This commit is contained in:
Akim Demaille
2020-05-07 08:00:17 +02:00
parent 1b4108da3e
commit d26d10ad6c
2 changed files with 26 additions and 10 deletions

View File

@@ -34,6 +34,13 @@ cwd=$(pwd)
# See bistromathic.test.
strip_prompt=false
# If diff supports --strip-trailing-cr, use it, to avoid EOL issues
# when testing Java programs on Windows.
echo "checking for diff --strip-trailing-cr"
if diff --strip-trailing-cr "$1" "$1"; then
diff_opts=--strip-trailing-cr
fi
# The exercised program.
abs_medir=$cwd/examples/$medir
if test -x "$abs_medir/$me"; then
@@ -129,7 +136,7 @@ run ()
} >eff
if test $sta_eff -eq $sta_exp; then
if diff eff exp >/dev/null 2>&1; then
if diff $diff_opts eff exp >/dev/null 2>&1; then
echo "$me: PASS: $number"
else
echo "$me: FAIL: $number"
@@ -140,7 +147,7 @@ run ()
echo "$me: effective output:"
sed -e 's/^/ /' eff
echo "$me: diff:"
diff -u exp eff | sed -e 's/^/ /'
diff $diff_opts -u exp eff | sed -e 's/^/ /'
status=1
fi
else