Skip to content

Commit 47c6d4d

Browse files
rjustogitster
authored andcommitted
test-lib: fix GIT_TEST_SANITIZE_LEAK_LOG
When a test that leaks runs with GIT_TEST_SANITIZE_LEAK_LOG=true, the test returns zero, which is not what we want. In the if-else's chain we have in "check_test_results_san_file_", we consider three variables: $passes_sanitize_leak, $sanitize_leak_check and, implicitly, GIT_TEST_SANITIZE_LEAK_LOG (always set to "true" at that point). For the first two variables we have different considerations depending on the value of $test_failure, which makes sense. However, for the third, GIT_TEST_SANITIZE_LEAK_LOG, we don't; regardless of $test_failure, we use "invert_exit_code=t" to produce a non-zero return value. That assumes "$test_failure" is always zero at that point. But it may not be: $ git checkout v2.40.1 $ make test SANITIZE=leak T=t3200-branch.sh # this fails $ make test SANITIZE=leak GIT_TEST_SANITIZE_LEAK_LOG=true T=t3200-branch.sh # this succeeds [...] With GIT_TEST_SANITIZE_LEAK_LOG=true, our logs revealed a memory leak, exiting with a non-zero status! # faked up failures as TODO & now exiting with 0 due to --invert-exit-code We need to use "invert_exit_code=t" only when "$test_failure" is zero. Let's add the missing conditions in the if-else's chain to make it work as expected. Helped-by: Eric Sunshine <[email protected]> Helped-by: Jeff King <[email protected]> Signed-off-by: Rubén Justo <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 09e5e7f commit 47c6d4d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

t/test-lib.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,12 @@ check_test_results_san_file_ () {
12691269
then
12701270
say "As TEST_PASSES_SANITIZE_LEAK=true isn't set the above leak is 'ok' with GIT_TEST_PASSING_SANITIZE_LEAK=check" &&
12711271
invert_exit_code=t
1272-
else
1272+
elif test "$test_failure" = 0
1273+
then
12731274
say "With GIT_TEST_SANITIZE_LEAK_LOG=true our logs revealed a memory leak, exit non-zero!" &&
12741275
invert_exit_code=t
1276+
else
1277+
say "With GIT_TEST_SANITIZE_LEAK_LOG=true our logs revealed a memory leak..."
12751278
fi
12761279
}
12771280

0 commit comments

Comments
 (0)