]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: move LSan errors from stdout to stderr
authorJeff King <peff@peff.net>
Tue, 30 Jun 2026 06:41:59 +0000 (02:41 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Jun 2026 18:23:59 +0000 (11:23 -0700)
When we find LSan errors, we dump them via "say_color", which goes to
stdout. This is mostly harmless, since stdout and stderr tend to go to
the same place (either the user's terminal, or to the ".out" file with
--verbose-log).

But when running under a TAP harness like prove, they are split and
stdout is interpreted as TAP output. Historically even this was fine, as
the extra lines on stdout would be ignored. But since 389c83025d (t: let
prove fail when parsing invalid TAP output, 2026-06-04) we instruct the
TAP reader to complain, and a leaking test will result in complaints
like this (this is a real leak which we have yet to fix):

  $ GIT_TEST_COMMIT_GRAPH=1 make SANITIZE=leak test
  [...]
  Test Summary Report
  -------------------
  t4014-format-patch.sh (Wstat: 256 (exited 1) Tests: 226 Failed: 30)
    Failed tests:  197-226
    Non-zero exit status: 1
    Parse errors: Unknown TAP token: ""
                  Unknown TAP token: "================================================================="
                  Unknown TAP token: "==git==3693658==ERROR: LeakSanitizer: detected memory leaks"
                  Unknown TAP token: ""
                  Unknown TAP token: "Direct leak of 200 byte(s) in 1 object(s) allocated from:"
  Displayed the first 5 of 1531 TAP syntax errors.
  Re-run prove with the -p option to see them all.

You still see the failing tests, so it's mostly just an annoyance. We
can fix it by redirecting to stderr (actually descriptor 4, which is our
verbose-respecting variant). I confirmed manually that the output still
appears with --verbose-log, and even with a single-test "-i
--verbose-only=197" going to the terminal.

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

index 70fd3e9bafb8007071ddbd6377fa7474fc2f7b74..63db941bb7bc2ceec9f2fca8f796cb4e8e4f657e 100644 (file)
@@ -1190,14 +1190,14 @@ check_test_results_san_file_ () {
        then
                return
        fi &&
-       say_color error "$(cat "$TEST_RESULTS_SAN_FILE".*)" &&
+       say_color >&4 error "$(cat "$TEST_RESULTS_SAN_FILE".*)" &&
 
        if test "$test_failure" = 0
        then
-               say "Our logs revealed a memory leak, exit non-zero!" &&
+               say >&4 "Our logs revealed a memory leak, exit non-zero!" &&
                invert_exit_code=t
        else
-               say "Our logs revealed a memory leak..."
+               say >&4 "Our logs revealed a memory leak..."
        fi
 }