diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2022-09-01 03:29:48 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-09-01 20:07:41 +0300 |
commit | a8f30ee0502b89ecb660af36784f653a8c3fb20d (patch) | |
tree | 35840694c510b0290bdc2f9a0a7b5df565ef879f /t/chainlint.pl | |
parent | aabc3258a1da5f06e0b2492f450d4b8e7e8137e5 (diff) |
chainlint.pl: don't flag broken &&-chain if `$?` handled explicitly
There are cases in which tests capture and check a command's exit code
explicitly without employing test_expect_code(). They do so by
intentionally breaking the &&-chain since it would be impossible to
capture "$?" in the failing case if the `status=$?` assignment was part
of the &&-chain. Since such constructs are manually checking the exit
code, their &&-chain breakage is legitimate and safe, thus should not be
flagged. Therefore, stop flagging &&-chain breakage in such cases.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/chainlint.pl')
-rwxr-xr-x | t/chainlint.pl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/t/chainlint.pl b/t/chainlint.pl index ba3fcb0c8e..14e1db3519 100755 --- a/t/chainlint.pl +++ b/t/chainlint.pl @@ -497,6 +497,12 @@ sub accumulate { # did previous command end with "&&", "|", "|| return" or similar? goto DONE if match_ending($tokens, \@safe_endings); + # if this command handles "$?" specially, then okay for previous + # command to be missing "&&" + for my $token (@$cmd) { + goto DONE if $token =~ /\$\?/; + } + # flag missing "&&" at end of previous command my $n = find_non_nl($tokens); splice(@$tokens, $n + 1, 0, '?!AMP?!') unless $n < 0; |