notes tests: don't ignore "git" exit code

Change a fragile test pattern that's been with us ever since these tests were introduced in [1], [2] and [3] to properly return the exit code of the failing command on failure. Because of this I'd marked this test as passing under SANITIZE=leak in [4] and [5]. We need to remove those annotations as these tests will no longer pass. 1. 9081a421a6d (checkout: fix "branch info" memory leaks, 2021-11-16) 2. 0057c0917d3 (Add selftests verifying that we can parse notes trees with various fanouts, 2009-10-09) 3. 048cdd4665e (t3305: Verify that adding many notes with git-notes triggers increased fanout, 2010-02-13) 4. ca089724952 (leak tests: mark some notes tests as passing with SANITIZE=leak, 2021-10-31) 5. 9081a421a6d (checkout: fix "branch info" memory leaks, 2021-11-16) Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 7, 2022 at 13:49 UTC b6d775dd38615f6371a57458fcb527aa0abfcbdf
3 files changed +14 -15
t/t3302-notes-index-expensive.sh
+3 -3
@@ -8,7 +8,6 @@ test_description='Test commit notes index (expensive!)'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
11 -TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
12
13 create_repo () {
@@ -65,7 +64,8 @@ create_repo () {
64 test_notes () {
65 count=$1 &&
66 git config core.notesRef refs/notes/commits &&
68 - git log | grep "^ " >output &&
67 + git log >tmp &&
68 + grep "^ " tmp >output &&
69 i=$count &&
70 while test $i -gt 0
71 do
@@ -90,7 +90,7 @@ write_script time_notes <<\EOF
90 unset GIT_NOTES_REF
91 ;;
92 esac
93 - git log
93 + git log || exit $?
94 i=$(($i+1))
95 done >/dev/null
96 EOF
t/t3303-notes-subtrees.sh
+4 -5
@@ -5,7 +5,6 @@ test_description='Test commit notes organized in subtrees'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 -TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
9
10 number_of_commits=100
@@ -79,7 +78,7 @@ test_sha1_based () {
78 (
79 start_note_commit &&
80 nr=$number_of_commits &&
82 - git rev-list refs/heads/main |
81 + git rev-list refs/heads/main >out &&
82 while read sha1; do
83 note_path=$(echo "$sha1" | sed "$1")
84 cat <<INPUT_END &&
@@ -91,9 +90,9 @@ EOF
90 INPUT_END
91
92 nr=$(($nr-1))
94 - done
95 - ) |
96 - git fast-import --quiet
93 + done <out
94 + ) >gfi &&
95 + git fast-import --quiet <gfi
96 }
97
98 test_expect_success 'test notes in 2/38-fanout' 'test_sha1_based "s|^..|&/|"'
t/t3305-notes-fanout.sh
+7 -7
@@ -2,7 +2,6 @@
2
3 test_description='Test that adding/removing many notes triggers automatic fanout restructuring'
4
5 -TEST_PASSES_SANITIZE_LEAK=true
5 . ./test-lib.sh
6
7 path_has_fanout() {
@@ -24,7 +23,7 @@ touched_one_note_with_fanout() {
23 all_notes_have_fanout() {
24 notes_commit=$1 &&
25 fanout=$2 &&
27 - git ls-tree -r --name-only $notes_commit 2>/dev/null |
26 + git ls-tree -r --name-only $notes_commit |
27 while read path
28 do
29 path_has_fanout $path $fanout || return 1
@@ -51,8 +50,9 @@ test_expect_success 'creating many notes with git-notes' '
50 done
51 '
52
54 -test_expect_success 'many notes created correctly with git-notes' '
55 - git log | grep "^ " > output &&
53 +test_expect_success !SANITIZE_LEAK 'many notes created correctly with git-notes' '
54 + git log >output.raw &&
55 + grep "^ " output.raw >output &&
56 i=$num_notes &&
57 while test $i -gt 0
58 do
@@ -91,13 +91,13 @@ test_expect_success 'stable fanout 0 is followed by stable fanout 1' '
91 test_expect_success 'deleting most notes with git-notes' '
92 remove_notes=285 &&
93 i=0 &&
94 - git rev-list HEAD |
94 + git rev-list HEAD >revs &&
95 while test $i -lt $remove_notes && read sha1
96 do
97 i=$(($i + 1)) &&
98 test_tick &&
99 - git notes remove "$sha1" 2>/dev/null || return 1
100 - done
99 + git notes remove "$sha1" || return 1
100 + done <revs
101 '
102
103 test_expect_success 'most notes deleted correctly with git-notes' '