git/t/chainlint
Eric Sunshine 2b61c8dc88 tests: diagnose unclosed here-doc in chainlint.pl
An unclosed here-doc in a test is a problem, because it silently gobbles
up any remaining commands. Since 99a64e4b73 (tests: lint for run-away
here-doc, 2017-03-22) we detect this by piggy-backing on the internal
chainlint checker in test-lib.sh.

However, it would be nice to detect it in chainlint.pl, for a few
reasons:

  - the output from chainlint.pl is much nicer; it can show the exact
    spot of the error, rather than a vague "somewhere in this test you
    broke the &&-chain or had a bad here-doc" message.

  - the implementation in test-lib.sh runs for each test snippet. And
    since it requires a subshell, the extra cost is small but not zero.
    If chainlint.pl can reliably find the problem, we can optimize the
    test-lib.sh code.

The chainlint.pl code never intended to find here-doc problems. But
since it has to parse them anyway (to avoid reporting problems inside
here-docs), most of what we need is already there. We can detect the
problem when we fail to find the missing end-tag in swallow_heredocs().
The extra change in scan_heredoc_tag() stores the location of the start
of the here-doc, which lets us mark it as the source of the error in the
output (see the new tests for examples).

[jk: added commit message and tests]

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-03-30 13:07:29 -07:00
..
arithmetic-expansion.expect
arithmetic-expansion.test
bash-array.expect
bash-array.test
blank-line-before-esac.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
blank-line-before-esac.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
blank-line.expect
blank-line.test
block-comment.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
block-comment.test
block.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
block.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
broken-chain.expect
broken-chain.test
case-comment.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
case-comment.test
case.expect
case.test
chain-break-background.expect
chain-break-background.test
chain-break-continue.expect
chain-break-continue.test
chain-break-false.expect
chain-break-false.test
chain-break-return-exit.expect
chain-break-return-exit.test
chain-break-status.expect
chain-break-status.test
chained-block.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
chained-block.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
chained-subshell.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
chained-subshell.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
close-nested-and-parent-together.expect
close-nested-and-parent-together.test
close-subshell.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
close-subshell.test
command-substitution-subsubshell.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
command-substitution-subsubshell.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
command-substitution.expect
command-substitution.test
comment.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
comment.test
complex-if-in-cuddled-loop.expect chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
complex-if-in-cuddled-loop.test
cuddled-if-then-else.expect
cuddled-if-then-else.test
cuddled-loop.expect
cuddled-loop.test
cuddled.expect
cuddled.test
double-here-doc.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
double-here-doc.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
dqstring-line-splice.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
dqstring-line-splice.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
dqstring-no-interpolate.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
dqstring-no-interpolate.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
empty-here-doc.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
empty-here-doc.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
exclamation.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
exclamation.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
exit-loop.expect
exit-loop.test
exit-subshell.expect
exit-subshell.test
for-loop-abbreviated.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
for-loop-abbreviated.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
for-loop.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
for-loop.test
function.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
function.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
here-doc-close-subshell.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
here-doc-close-subshell.test
here-doc-indent-operator.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
here-doc-indent-operator.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
here-doc-multi-line-command-subst.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
here-doc-multi-line-command-subst.test
here-doc-multi-line-string.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
here-doc-multi-line-string.test
here-doc.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
here-doc.test
if-condition-split.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
if-condition-split.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
if-in-loop.expect
if-in-loop.test
if-then-else.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
if-then-else.test
incomplete-line.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
incomplete-line.test
inline-comment.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
inline-comment.test
loop-detect-failure.expect chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
loop-detect-failure.test chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
loop-detect-status.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
loop-detect-status.test chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
loop-in-if.expect chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
loop-in-if.test
loop-upstream-pipe.expect chainlint.pl: allow || echo to signal failure upstream of a pipe 2022-09-01 10:07:41 -07:00
loop-upstream-pipe.test chainlint.pl: allow || echo to signal failure upstream of a pipe 2022-09-01 10:07:41 -07:00
multi-line-nested-command-substitution.expect
multi-line-nested-command-substitution.test
multi-line-string.expect
multi-line-string.test
negated-one-liner.expect
negated-one-liner.test
nested-cuddled-subshell.expect
nested-cuddled-subshell.test
nested-here-doc.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
nested-here-doc.test
nested-loop-detect-failure.expect chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
nested-loop-detect-failure.test chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
nested-subshell-comment.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
nested-subshell-comment.test
nested-subshell.expect
nested-subshell.test
not-heredoc.expect
not-heredoc.test
one-liner-for-loop.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
one-liner-for-loop.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
one-liner.expect
one-liner.test
p4-filespec.expect
p4-filespec.test
pipe.expect
pipe.test
return-loop.expect
return-loop.test
semicolon.expect chainlint.pl: complain about loops lacking explicit failure handling 2022-09-01 10:07:41 -07:00
semicolon.test
sqstring-in-sqstring.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
sqstring-in-sqstring.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
subshell-here-doc.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
subshell-here-doc.test
subshell-one-liner.expect
subshell-one-liner.test
t7900-subtree.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
t7900-subtree.test
token-pasting.expect t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
token-pasting.test t/chainlint: add more chainlint.pl self-tests 2022-09-01 10:07:41 -07:00
unclosed-here-doc-indent.expect tests: diagnose unclosed here-doc in chainlint.pl 2023-03-30 13:07:29 -07:00
unclosed-here-doc-indent.test tests: diagnose unclosed here-doc in chainlint.pl 2023-03-30 13:07:29 -07:00
unclosed-here-doc.expect tests: diagnose unclosed here-doc in chainlint.pl 2023-03-30 13:07:29 -07:00
unclosed-here-doc.test tests: diagnose unclosed here-doc in chainlint.pl 2023-03-30 13:07:29 -07:00
while-loop.expect chainlint: annotate original test definition rather than token stream 2022-11-08 15:10:49 -05:00
while-loop.test