mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 16:53:02 +00:00
examples: beware of readline on macOS
macOS' version of readline does not repeat stdin on stdout in non-interactive mode, contrary to the current version of GNU readline. * examples/test: Add support for strip_prompt. * examples/c/bistromathic/bistromathic.test (strip_prompt): Set it when needed. Early exit when needed.
This commit is contained in:
@@ -15,6 +15,12 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# macOS' version of readline does not repeat stdin on stdout in
|
||||||
|
# non-interactive mode.
|
||||||
|
if ! echo '1-1' | prog | grep '1-1'; then
|
||||||
|
strip_prompt=true
|
||||||
|
fi
|
||||||
|
|
||||||
cat >input <<EOF
|
cat >input <<EOF
|
||||||
1+2*3
|
1+2*3
|
||||||
EOF
|
EOF
|
||||||
@@ -85,6 +91,17 @@ run 0 '> 1 / 0
|
|||||||
## Completion. ##
|
## Completion. ##
|
||||||
## ------------ ##
|
## ------------ ##
|
||||||
|
|
||||||
|
# From now on, the differences between versions of GNU Readline are
|
||||||
|
# too painful to try to cope with.
|
||||||
|
if $strip_prompt; then
|
||||||
|
echo "SKIP: this is not the GNU Readline we expect"
|
||||||
|
if $exit; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check completion after an operator.
|
# Check completion after an operator.
|
||||||
sed -e 's/\\t/ /g' >input <<EOF
|
sed -e 's/\\t/ /g' >input <<EOF
|
||||||
(1+\t\t
|
(1+\t\t
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ exit=true
|
|||||||
# top_builddir.
|
# top_builddir.
|
||||||
cwd=$(pwd)
|
cwd=$(pwd)
|
||||||
|
|
||||||
|
# Whether to strip '> ...' lines from the expected output.
|
||||||
|
# See bistromathic.test.
|
||||||
|
strip_prompt=false
|
||||||
|
|
||||||
# The exercised program.
|
# The exercised program.
|
||||||
abs_medir=$cwd/examples/$medir
|
abs_medir=$cwd/examples/$medir
|
||||||
if test -x "$abs_medir/$me"; then
|
if test -x "$abs_medir/$me"; then
|
||||||
@@ -77,14 +81,23 @@ run ()
|
|||||||
# Expected exit status.
|
# Expected exit status.
|
||||||
sta_exp=$1
|
sta_exp=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# Expected output.
|
# Expected output.
|
||||||
out_exp=$1
|
if $strip_prompt; then
|
||||||
|
out_exp=$(echo "$1" | sed -e 's/^> err:/err:/;/^> /d')
|
||||||
|
else
|
||||||
|
out_exp=$1
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# Effective exit status.
|
# Effective exit status.
|
||||||
sta_eff=0
|
sta_eff=0
|
||||||
|
|
||||||
prog "$@" - <input >out_eff 2>err_eff || sta_eff=$?
|
prog "$@" - <input >out_eff 2>err_eff || sta_eff=$?
|
||||||
|
|
||||||
# Combine effective output and error streams.
|
# Combine effective output and error streams.
|
||||||
out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff)
|
out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff)
|
||||||
|
|
||||||
if test $sta_eff -eq $sta_exp; then
|
if test $sta_eff -eq $sta_exp; then
|
||||||
if test "$out_eff" = "$out_exp"; then
|
if test "$out_eff" = "$out_exp"; then
|
||||||
echo "$me: PASS: $number"
|
echo "$me: PASS: $number"
|
||||||
|
|||||||
Reference in New Issue
Block a user