Skip to content

Commit cf14643

Browse files
peffgitster
authored andcommitted
test-lib: check for leak logs after every test
If you are trying to find and fix leaks in a large test script, it can be overwhelming to see the leak logs for every test at once. The previous commit let you use "--immediate" to see the logs after the first failing test, but this isn't always the first leak. As discussed there, we may see leaks from previous tests that didn't happen to fail. To catch those, let's check for any logs that appeared after each test snippet is run, meaning that in a SANITIZE=leak build, any leak is an immediate failure of the test snippet. This check is mostly free in non-leak builds (just a "test -z"), and only a few extra processes in a leak build, so I don't think the overhead should matter (if it does, we could probably optimize for the common "no logs" case without even spending a process). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fabf6e commit cf14643

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

t/test-lib-functions.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,8 @@ test_expect_success () {
926926
test_body_or_stdin test_body "$2"
927927
test -n "$test_skip_test_preamble" ||
928928
say >&3 "expecting success of $TEST_NUMBER.$test_count '$1': $test_body"
929-
if test_run_ "$test_body"
929+
if test_run_ "$test_body" &&
930+
check_test_results_san_file_empty_
930931
then
931932
test_ok_ "$1"
932933
else

t/test-lib.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,12 +1215,13 @@ test_atexit_handler () {
12151215
teardown_malloc_check
12161216
}
12171217

1218+
check_test_results_san_file_empty_ () {
1219+
test -z "$TEST_RESULTS_SAN_FILE" ||
1220+
test "$(nr_san_dir_leaks_)" = 0
1221+
}
1222+
12181223
check_test_results_san_file_ () {
1219-
if test -z "$TEST_RESULTS_SAN_FILE"
1220-
then
1221-
return
1222-
fi &&
1223-
if test "$(nr_san_dir_leaks_)" = 0
1224+
if check_test_results_san_file_empty_
12241225
then
12251226
return
12261227
fi &&

0 commit comments

Comments
 (0)