Skip to content

Commit a9539a9

Browse files
pks-tgitster
authored andcommitted
t/test-lib: allow skipping leak checks for passing tests
With `GIT_TEST_PASSING_SANITIZE_LEAK=check`, one can double check whether a memory leak fix caused some test suites to become leak free. This is done by running all tests with the leak checker enabled. If a test suite does not declare `TEST_PASSES_SANITIZE_LEAK=true` but still finishes successfully with the leak checker enabled, then this indicates that the test is leak free and thus missing the annotation. It is somewhat slow to execute though because it runs all of our test suites with the leak sanitizer enabled. It is also pointless in most cases, because the only test suites that need to be checked are those which _aren't_ yet marked with `TEST_PASSES_SANITIZE_LEAK=true`. Introduce a new value "check-failing". When set, we behave the same as if "check" was passed, except that we only check those tests which do not have `TEST_PASSES_SANITIZE_LEAK=true` set. This is significantly faster than running all test suites but still fulfills the usecase of finding newly-leak-free test suites. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6a09c36 commit a9539a9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

t/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ GIT_TEST_PASSING_SANITIZE_LEAK=check when combined with "--immediate"
386386
will run to completion faster, and result in the same failing
387387
tests.
388388

389+
GIT_TEST_PASSING_SANITIZE_LEAK=check-failing behaves the same as "check",
390+
but skips all tests which are already marked as leak-free.
391+
389392
GIT_TEST_PROTOCOL_VERSION=<n>, when set, makes 'protocol.version'
390393
default to n.
391394

t/test-lib.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,16 @@ then
15581558
passes_sanitize_leak=t
15591559
fi
15601560

1561-
if test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check"
1561+
if test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
1562+
test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check-failing"
15621563
then
1564+
if test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check-failing" &&
1565+
test -n "$passes_sanitize_leak"
1566+
then
1567+
skip_all="skipping leak-free $this_test under GIT_TEST_PASSING_SANITIZE_LEAK=check-failing"
1568+
test_done
1569+
fi
1570+
15631571
sanitize_leak_check=t
15641572
if test -n "$invert_exit_code"
15651573
then
@@ -1597,6 +1605,7 @@ then
15971605
export LSAN_OPTIONS
15981606

15991607
elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
1608+
test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check-failing" ||
16001609
test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
16011610
then
16021611
BAIL_OUT_ENV_NEEDS_SANITIZE_LEAK "GIT_TEST_PASSING_SANITIZE_LEAK=true"

0 commit comments

Comments
 (0)