Skip to content

Commit 4e9fdcc

Browse files
authored
Merge pull request DeusData#1879 from DeusData/fix/venue-parity-probe-sigpipe
fix(tests): venue-parity interface probes must not pipe into grep -q
2 parents 31b611a + cbd241d commit 4e9fdcc

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎tests/test_venue_parity_contract.sh‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,16 @@ test-infrastructure/vm/win.sh
401401
case "$entry" in
402402
*.py) out=$(cd "$ROOT" && python3 "$entry" --help 2>&1) && rc=0 || rc=$? ;;
403403
esac
404-
if [ "$rc" -ne 0 ] || ! printf '%s' "$out" | grep -q "Usage:"; then
404+
# Substring test in-shell: piping into `grep -q` is unsafe under
405+
# `set -o pipefail` because grep exits at the first match and the
406+
# writer takes EPIPE on any payload larger than the pipe buffer,
407+
# turning a SATISFIED contract into a probe failure (macOS, 698-byte
408+
# --help vs a 512-byte PIPE_BUF).
409+
case "$out" in
410+
*"Usage:"*) has_usage=1 ;;
411+
*) has_usage=0 ;;
412+
esac
413+
if [ "$rc" -ne 0 ] || [ "$has_usage" -eq 0 ]; then
405414
echo "INTERFACE CONTRACT: $entry --help must exit 0 and print a Usage: block (rc=$rc)" >&2
406415
probe_failures=1
407416
fi
@@ -422,7 +431,11 @@ scripts/smoke-invariants.sh
422431
"
423432
for entry in $STRICT_ENTRIES; do
424433
out=$(cd "$ROOT" && bash "$entry" --definitely-not-a-flag 2>&1) && rc=0 || rc=$?
425-
if [ "$rc" -ne 2 ] || ! printf '%s' "$out" | grep -q "Please consult --help."; then
434+
case "$out" in
435+
*"Please consult --help."*) has_hint=1 ;;
436+
*) has_hint=0 ;;
437+
esac
438+
if [ "$rc" -ne 2 ] || [ "$has_hint" -eq 0 ]; then
426439
echo "INTERFACE CONTRACT: $entry must reject unknown flags with exit 2 + 'Please consult --help.' (rc=$rc)" >&2
427440
probe_failures=1
428441
fi

0 commit comments

Comments
 (0)