]> git.ipfire.org Git - thirdparty/git.git/commit
test-lib: move malloc-debug setup after $PATH setup
authorJeff King <peff@peff.net>
Thu, 14 Nov 2024 01:39:12 +0000 (20:39 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Nov 2024 03:19:26 +0000 (12:19 +0900)
commit72ad6dc368892803c761fe3d82b98eb2555e4fbc
treeaeead26c01edd35e1d6776a71a5276906f374275
parent02d900361c2b1e5d1fab006d2e71c8dc8bda8ca1
test-lib: move malloc-debug setup after $PATH setup

Originally, the conditional definition of the setup/teardown functions
for malloc checking could be run at any time, because they depended only
on command-line options and the system getconf function.

But since 02d900361c (test-lib: check malloc debug LD_PRELOAD before
using, 2024-11-11), we probe the system by running "git version". Since
this code runs before we've set $PATH to point to the version of Git we
intend to test, we actually run the system version of git.

This mostly works, since what we really care about is whether the
LD_PRELOAD works, and it should work the same with any program. But
there are some corner cases:

  1. You might not have a system git at all, in which case the preload
     will appear to fail, even though it could work with the actual
     built version of git.

  2. Your system git could be linked in a different way. For example, if
     it was built statically, then it will ignore LD_PRELOAD entirely,
     and we might assume that the preload works, even though it might
     not when used with a dynamic build.

We could give a more complete path to the version of Git we intend to
test, but features like GIT_TEST_INSTALLED make that not entirely
trivial. So instead, let's just bump the setup until after we've set up
the $PATH. There's no need for us to do it early, as long as it is done
before the first test runs.

Reported-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh