Skip to content

Commit 373a432

Browse files
peffgitster
authored andcommitted
test-lib: simplify leak-log checking
We have a function to count the number of leaks found (actually, it is the number of processes which produced a log file). Once upon a time we cared about seeing if this number increased between runs. But we simplified that away in 95c679a (test-lib: stop showing old leak logs, 2024-09-24), and now we only care if it returns any results or not. In preparation for refactoring it further, let's drop the counting function entirely, and roll it into the "is it empty" check. The outcome should be the same, but we'll be free to return a boolean "did we find anything" without worrying about somebody adding a new call to the counting function. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fa0c4d commit 373a432

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

t/test-lib.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,6 @@ case "$TRASH_DIRECTORY" in
340340
*) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
341341
esac
342342

343-
# Utility functions using $TEST_RESULTS_* variables
344-
nr_san_dir_leaks_ () {
345-
# stderr piped to /dev/null because the directory may have
346-
# been "rmdir"'d already.
347-
find "$TEST_RESULTS_SAN_DIR" \
348-
-type f \
349-
-name "$TEST_RESULTS_SAN_FILE_PFX.*" 2>/dev/null |
350-
xargs grep -lv "Unable to get registers from thread" |
351-
wc -l
352-
}
353-
354343
# If --stress was passed, run this test repeatedly in several parallel loops.
355344
if test "$GIT_TEST_STRESS_STARTED" = "done"
356345
then
@@ -1181,8 +1170,14 @@ test_atexit_handler () {
11811170
}
11821171

11831172
check_test_results_san_file_empty_ () {
1184-
test -z "$TEST_RESULTS_SAN_FILE" ||
1185-
test "$(nr_san_dir_leaks_)" = 0
1173+
test -z "$TEST_RESULTS_SAN_FILE" && return 0
1174+
1175+
# stderr piped to /dev/null because the directory may have
1176+
# been "rmdir"'d already.
1177+
! find "$TEST_RESULTS_SAN_DIR" \
1178+
-type f \
1179+
-name "$TEST_RESULTS_SAN_FILE_PFX.*" 2>/dev/null |
1180+
xargs grep -qv "Unable to get registers from thread"
11861181
}
11871182

11881183
check_test_results_san_file_ () {

0 commit comments

Comments
 (0)