]> git.ipfire.org Git - thirdparty/git.git/commit
chainlint.pl: recognize test bodies defined via heredoc
authorEric Sunshine <sunshine@sunshineco.com>
Wed, 10 Jul 2024 08:38:31 +0000 (04:38 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Jul 2024 17:14:22 +0000 (10:14 -0700)
commita4a5f282f58f16a472ec2b08f5dc06ee149a9700
tree0d3ad27a4f85ee3580e2ee75500d96a907774f84
parent03763e68fb7fc4b37dd2d184dde501618e6c171d
chainlint.pl: recognize test bodies defined via heredoc

In order to check tests for semantic problems, chainlint.pl scans test
scripts, looking for tests defined as:

    test_expect_success [prereq] title '
        body
    '

where `body` is a single string which is then treated as a standalone
chunk of code and "linted" to detect semantic issues. (The same happens
for `test_expect_failure` definitions.)

The introduction of test definitions in which the test body is instead
presented via a heredoc rather than as a single string creates a blind
spot in the linting process since such invocations are not recognized by
chainlint.pl.

Prepare for this new style by also recognizing tests defined as:

    test_expect_success [prereq] title - <<\EOT
        body
    EOT

A minor complication is that chainlint.pl has never considered heredoc
bodies significant since it doesn't scan them for semantic problems,
thus it has always simply thrown them away. However, with the new
`test_expect_success` calling sequence, heredoc bodies become
meaningful, thus need to be captured.

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>
t/chainlint.pl