Skip to content

Commit 99a64e4

Browse files
committed
tests: lint for run-away here-doc
We found a few run-away here documents that are started with an end-of-here-doc marker that is incorrectly spelled, e.g. git some command >actual && cat <<EOF >expect ... EOF && test_cmp expect actual which ends up slurping the entire remainder of the script as if it were the data. Often the command that gets misused like this exits without failure (e.g. "cat" in the above example), which makes the command appear to work, without ever executing the remainder of the test. Piggy-back on the test that catches &&-chain breakage to detect this case as well. Signed-off-by: Junio C Hamano <[email protected]>
1 parent f364f02 commit 99a64e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

t/test-lib.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,9 @@ test_run_ () {
624624
trace=
625625
# 117 is magic because it is unlikely to match the exit
626626
# code of other programs
627-
test_eval_ "(exit 117) && $1"
628-
if test "$?" != 117; then
629-
error "bug in the test script: broken &&-chain: $1"
627+
if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
628+
then
629+
error "bug in the test script: broken &&-chain or run-away HERE-DOC: $1"
630630
fi
631631
trace=$trace_tmp
632632
fi

0 commit comments

Comments
 (0)