Skip to content

Commit 495ab70

Browse files
peffdscho
authored andcommitted
test-lib: invert return value of check_test_results_san_file_empty
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5cc2d6c commit 495ab70

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

t/test-lib-functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ test_expect_success () {
927927
test -n "$test_skip_test_preamble" ||
928928
say >&3 "expecting success of $TEST_NUMBER.$test_count '$1': $test_body"
929929
if test_run_ "$test_body" &&
930-
check_test_results_san_file_empty_
930+
! check_test_results_san_file_has_entries_
931931
then
932932
test_ok_ "$1"
933933
else

t/test-lib.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,20 +1169,20 @@ test_atexit_handler () {
11691169
teardown_malloc_check
11701170
}
11711171

1172-
check_test_results_san_file_empty_ () {
1173-
test -z "$TEST_RESULTS_SAN_FILE" && return 0
1172+
check_test_results_san_file_has_entries_ () {
1173+
test -z "$TEST_RESULTS_SAN_FILE" && return 1
11741174

11751175
# stderr piped to /dev/null because the directory may have
11761176
# been "rmdir"'d already.
1177-
! find "$TEST_RESULTS_SAN_DIR" \
1177+
find "$TEST_RESULTS_SAN_DIR" \
11781178
-type f \
11791179
-name "$TEST_RESULTS_SAN_FILE_PFX.*" 2>/dev/null |
11801180
xargs grep ^DEDUP_TOKEN |
11811181
grep -qv sanitizer::GetThreadStackTopAndBottom
11821182
}
11831183

11841184
check_test_results_san_file_ () {
1185-
if check_test_results_san_file_empty_
1185+
if ! check_test_results_san_file_has_entries_
11861186
then
11871187
return
11881188
fi &&

0 commit comments

Comments
 (0)