1
0
mirror of https://github.com/git/git.git synced 2024-10-21 06:59:20 +02:00
git/t/chainlint
Eric Sunshine d73f5cfa89 chainlint.sed: stop splitting "(..." into separate lines "(" and "..."
Because `sed` is line-oriented, for ease of implementation, when
chainlint.sed encounters an opening subshell in which the first command
is cuddled with the "(", it splits the line into two lines: one
containing only "(", and the other containing whatever follows "(".
This allows chainlint.sed to get by with a single set of regular
expressions for matching shell statements rather than having to
duplicate each expression (one set for matching non-cuddled statements,
and one set for matching cuddled statements).

However, although syntactically and semantically immaterial, this
transformation has no value to test authors and might even confuse them
into thinking that the linter is misbehaving by inserting (whitespace)
line-noise into the shell code it is validating. Moreover, it also
allows an implementation detail of chainlint.sed to seep into the
chainlint self-test "expect" files, which potentially makes it difficult
to reuse the self-tests should a more capable chainlint ever be
developed.

To address these concerns, stop splitting cuddled "(..." into two lines.

Note that, as an implementation artifact, due to sed's line-oriented
nature, this change inserts a blank line at output time just before the
"(..." line is emitted. It would be possible to suppress this blank line
but doing so would add a fair bit of complexity to chainlint.sed.
Therefore, rather than suppressing the extra blank line, the Makefile's
`check-chainlint` target which runs the chainlint self-tests is instead
modified to ignore blank lines when comparing chainlint output against
the self-test "expect" output. This is a reasonable compromise for two
reasons. First, the purpose of the chainlint self-tests is to verify
that the ?!AMP?! annotations are being correctly added; precise
whitespace is immaterial. Second, by necessity, chainlint.sed itself
already throws away all blank lines within subshells since, when
checking for a broken &&-chain, it needs to check the final _statement_
in a subshell, not the final _line_ (which might be blank), thus it has
never made any attempt to precisely reproduce blank lines in its output.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-12-13 14:15:29 -08:00
..
arithmetic-expansion.expect
arithmetic-expansion.test
bash-array.expect
bash-array.test
blank-line.expect
blank-line.test
block-comment.expect
block-comment.test
block.expect
block.test
broken-chain.expect
broken-chain.test
case-comment.expect
case-comment.test
case.expect
case.test
close-nested-and-parent-together.expect
close-nested-and-parent-together.test
close-subshell.expect
close-subshell.test
command-substitution.expect
command-substitution.test
comment.expect
comment.test
complex-if-in-cuddled-loop.expect
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
exit-loop.expect
exit-loop.test
exit-subshell.expect
exit-subshell.test
for-loop.expect
for-loop.test
here-doc-close-subshell.expect
here-doc-close-subshell.test
here-doc-multi-line-command-subst.expect
here-doc-multi-line-command-subst.test
here-doc-multi-line-string.expect
here-doc-multi-line-string.test
here-doc.expect
here-doc.test
if-in-loop.expect
if-in-loop.test
if-then-else.expect
if-then-else.test
incomplete-line.expect
incomplete-line.test
inline-comment.expect
inline-comment.test
loop-in-if.expect
loop-in-if.test
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
nested-here-doc.test
nested-subshell-comment.expect
nested-subshell-comment.test
nested-subshell.expect
nested-subshell.test
not-heredoc.expect
not-heredoc.test
one-liner.expect
one-liner.test
p4-filespec.expect
p4-filespec.test
pipe.expect
pipe.test
semicolon.expect
semicolon.test
subshell-here-doc.expect
subshell-here-doc.test
subshell-one-liner.expect
subshell-one-liner.test
t7900-subtree.expect
t7900-subtree.test
while-loop.expect
while-loop.test