]> git.ipfire.org Git - thirdparty/git.git/commit
auto-crlf tests: don't lose exit code in loops and outside tests
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 6 Feb 2023 22:44:28 +0000 (23:44 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Feb 2023 23:30:41 +0000 (15:30 -0800)
commitfb18dd2831323d5dece711cdbcaa9dcd8bf4edab
tree2e0f7a1587ddb4a92ad3ab8faf01b8b6cb4d7a52
parentc48035d29b4e524aed3a32f0403676f0d9128863
auto-crlf tests: don't lose exit code in loops and outside tests

Change the functions which are called from within
"test_expect_success" to add the "|| return 1" idiom to their
for-loops, so we won't lose the exit code of "cp", "git" etc.

Then for those setup functions that aren't called from a
"test_expect_success" we need to put the setup code in a
"test_expect_success" as well. It would not be enough to properly
&&-chain these, as the calling code is the top-level script itself. As
we don't run the tests with "set -e" we won't report failing commands
at the top-level.

The "checkout" part of this would miss memory leaks under
SANITIZE=leak, this code doesn't leak (the relevant "git checkout"
leak has been fixed), but in a past version of git we'd continue past
this failure under SANITIZE=leak when these invocations had errored
out, even under "--immediate".

For checkout_files() we could run one test_expect_success() instead of
the 5 we run now in a loop.

But as this function added in [1] is already taking pains to split up
its setup into phases (there are 5 more "test_expect_success()" at the
end of it already, see [1]), let's follow that existing convention.

1. 343151dcbdf (t0027: combinations of core.autocrlf, core.eol and text, 2014-06-29)

Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0027-auto-crlf.sh