summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-23 05:43:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-24 03:56:49 (GMT)
commit99a64e4b73c38b5cb32dea5d4bd71c70079cae15 (patch)
tree200a3f9d058fb6faa54b7668710930e732660a39
parentf364f02724d6ce4c64fae85a86e0452b5634ddf8 (diff)
downloadgit-99a64e4b73c38b5cb32dea5d4bd71c70079cae15.zip
git-99a64e4b73c38b5cb32dea5d4bd71c70079cae15.tar.gz
git-99a64e4b73c38b5cb32dea5d4bd71c70079cae15.tar.bz2
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 <gitster@pobox.com>
-rw-r--r--t/test-lib.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 86d77c1..d5f2b70 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -624,9 +624,9 @@ test_run_ () {
trace=
# 117 is magic because it is unlikely to match the exit
# code of other programs
- test_eval_ "(exit 117) && $1"
- if test "$?" != 117; then
- error "bug in the test script: broken &&-chain: $1"
+ if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
+ then
+ error "bug in the test script: broken &&-chain or run-away HERE-DOC: $1"
fi
trace=$trace_tmp
fi