mirror of
https://github.com/git/git.git
synced 2026-06-19 15:39:47 +02:00
f1b0af0c61
Without a lint guard, bare grep assertions will creep back into tests over time, defeating the previous commit's conversion. Add greplint.pl to catch bare 'grep' used as a test assertion (where 'test_grep' should be used) and '! test_grep' (where 'test_grep !' should be used). greplint.pl reuses the shared shell parser from lib-shell-parser.pl to tokenize test bodies. The Lexer collapses heredocs, command substitutions, and quoted strings into single tokens, so 'grep' appearing inside these contexts is not flagged. A flat walk over the token stream tracks command position and pipeline state to distinguish assertion greps from filter greps. For double-quoted test bodies, a source-line walk counts backslash-continuation lines that the Lexer consumes without emitting into the body text, adjusting the reported line number accordingly. Add test fixtures in greplint/ (modeled on chainlint/) covering detection of bare grep assertions, correct skipping of filters, pipelines, redirects, command substitutions, and lint-ok annotations. Wire into the Makefile as: - test-greplint: runs greplint.pl on $(T) $(THELPERS) $(TPERF) - check-greplint: runs greplint.pl on fixtures, diffs against expected - clean-greplint: removes temp dir Add eol=lf entries in t/.gitattributes for greplint fixtures, matching chainlint, so that check-greplint passes on Windows where core.autocrlf would otherwise cause CRLF mismatches between expected and actual output. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 lines
371 B
Plaintext
12 lines
371 B
Plaintext
# Double-quoted test bodies with backslash-continuation lines:
|
|
# the splice adjustment in check_test compensates for \<newline>
|
|
# lines that the lexer consumes without emitting into the body
|
|
# text, so the reported line number matches the source.
|
|
test_expect_success 'dqstring continuation offset' "
|
|
x=\$(echo \
|
|
hello) &&
|
|
y=\$(echo \
|
|
world) &&
|
|
grep pattern file
|
|
"
|