]> git.ipfire.org Git - thirdparty/git.git/commit
test-lib: show leak-sanitizer logs on --immediate failure
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 21:36:36 +0000 (17:36 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:23:01 +0000 (10:23 -0700)
commit5fabf6e5ad28dab9c2c5944a9d4d4c5ab7720885
tree18f5b8dd3cd236c226ed2155b654bc073fc9c822
parent95c679ad861403d12178f871834bf3aa69981bc6
test-lib: show leak-sanitizer logs on --immediate failure

When we've compiled with SANITIZE=leak, at the end of the test script
we'll dump any collected logs to stdout. These logs have two uses:

  1. Leaks don't always cause a test snippet to fail (e.g., if they
     happen in a sub-process that we expect to return non-zero).
     Checking the logs catches these cases that we'd otherwise miss
     entirely.

  2. LSan will dump the leak info to stderr, but that is sometimes
     hidden (e.g., because it's redirected by the test, or because it's
     in a sub-process whose stderr goes elsewhere). Dumping the logs is
     the easiest way for the developer to see them.

One downside is that the set of logs for an entire script may be very
long, especially when you're trying to fix existing test scripts. You
can run with --immediate to stop at the first failing test, which means
we'll have accrued fewer logs. But we don't show the logs in that case!

Let's start doing so. This can only help case (2), of course (since it
depends on test failure). And it's somewhat weakened by the fact that
any cases of (1) will pollute the logs. But we can improve things
further in the next patch.

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