]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-lib: invert return value of check_test_results_san_file_empty
authorJeff King <peff@peff.net>
Tue, 7 Jan 2025 07:05:01 +0000 (02:05 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Jan 2025 16:09:14 +0000 (08:09 -0800)
We have a function to check whether LSan logged any leaks. It returns
success for no leaks, and non-zero otherwise. This is the simplest thing
for its callers, who want to say "if no leaks then return early". But
because it's implemented as a shell pipeline, you end up with the
awkward:

  ! find ... |
  xargs grep leaks |
  grep -v false-positives

where the "!" is actually negating the final grep. Switch the return
value (and name) to return success when there are leaks. This should
make the code a little easier to read, and the negation in the callers
still reads pretty naturally.

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

index 78e054ab503a6573ca9810a19d89afff334c6ba2..c25cee0ad8651ab34676c1550c07515655381277 100644 (file)
@@ -927,7 +927,7 @@ test_expect_success () {
                test -n "$test_skip_test_preamble" ||
                say >&3 "expecting success of $TEST_NUMBER.$test_count '$1': $test_body"
                if test_run_ "$test_body" &&
-                  check_test_results_san_file_empty_
+                  ! check_test_results_san_file_has_entries_
                then
                        test_ok_ "$1"
                else
index d1f62adbf829317153756c72511c187ffbb31cde..be3553e40e90529bdf126949d4bf1c83c2c9f0e9 100644 (file)
@@ -1169,12 +1169,12 @@ test_atexit_handler () {
        teardown_malloc_check
 }
 
-check_test_results_san_file_empty_ () {
-       test -z "$TEST_RESULTS_SAN_FILE" && return 0
+check_test_results_san_file_has_entries_ () {
+       test -z "$TEST_RESULTS_SAN_FILE" && return 1
 
        # stderr piped to /dev/null because the directory may have
        # been "rmdir"'d already.
-       find "$TEST_RESULTS_SAN_DIR" \
+       find "$TEST_RESULTS_SAN_DIR" \
                -type f \
                -name "$TEST_RESULTS_SAN_FILE_PFX.*" 2>/dev/null |
        xargs grep ^DEDUP_TOKEN |
@@ -1182,7 +1182,7 @@ check_test_results_san_file_empty_ () {
 }
 
 check_test_results_san_file_ () {
-       if check_test_results_san_file_empty_
+       if ! check_test_results_san_file_has_entries_
        then
                return
        fi &&