tests: use "test_stdout_line_count", not "test $(git [...] | wc -l)"
Use the test_stdout_line_count helper added in cdff1bb5a3d (test-lib-functions: introduce test_stdout_line_count, 2021-07-04) so that we'll spot if git itself dies, segfaults etc in these expressions. Because we didn't distinguish these failure conditions before I'd mistakenly marked these tests as passing under SANITIZE=leak in dd9cede9136 (leak tests: mark some rev-list tests as passing with SANITIZE=leak, 2021-10-31). While we're at it let's re-indent these lines to match our usual style, as we're having to change all of them anyway. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Mar 7, 2022 at 13:48 UTC
a182f69d5fb9fafead59eedbeb8a88a404ce3360
1 file changed
+21
-22
t/t6005-rev-list-count.sh
+21
-22
@@ -2,7 +2,6 @@
2
3
test_description='git rev-list --max-count and --skip test'
4
5
-TEST_PASSES_SANITIZE_LEAK=true
5
. ./test-lib.sh
6
7
test_expect_success 'setup' '
@@ -14,39 +13,39 @@ test_expect_success 'setup' '
13
'
14
15
test_expect_success 'no options' '
17
- test $(git rev-list HEAD | wc -l) = 5
16
+ test_stdout_line_count = 5 git rev-list HEAD
17
'
18
19
test_expect_success '--max-count' '
21
- test $(git rev-list HEAD --max-count=0 | wc -l) = 0 &&
22
- test $(git rev-list HEAD --max-count=3 | wc -l) = 3 &&
23
- test $(git rev-list HEAD --max-count=5 | wc -l) = 5 &&
24
- test $(git rev-list HEAD --max-count=10 | wc -l) = 5
20
+ test_stdout_line_count = 0 git rev-list HEAD --max-count=0 &&
21
+ test_stdout_line_count = 3 git rev-list HEAD --max-count=3 &&
22
+ test_stdout_line_count = 5 git rev-list HEAD --max-count=5 &&
23
+ test_stdout_line_count = 5 git rev-list HEAD --max-count=10
24
'
25
26
test_expect_success '--max-count all forms' '
28
- test $(git rev-list HEAD --max-count=1 | wc -l) = 1 &&
29
- test $(git rev-list HEAD -1 | wc -l) = 1 &&
30
- test $(git rev-list HEAD -n1 | wc -l) = 1 &&
31
- test $(git rev-list HEAD -n 1 | wc -l) = 1
27
+ test_stdout_line_count = 1 git rev-list HEAD --max-count=1 &&
28
+ test_stdout_line_count = 1 git rev-list HEAD -1 &&
29
+ test_stdout_line_count = 1 git rev-list HEAD -n1 &&
30
+ test_stdout_line_count = 1 git rev-list HEAD -n 1
31
'
32
33
test_expect_success '--skip' '
35
- test $(git rev-list HEAD --skip=0 | wc -l) = 5 &&
36
- test $(git rev-list HEAD --skip=3 | wc -l) = 2 &&
37
- test $(git rev-list HEAD --skip=5 | wc -l) = 0 &&
38
- test $(git rev-list HEAD --skip=10 | wc -l) = 0
34
+ test_stdout_line_count = 5 git rev-list HEAD --skip=0 &&
35
+ test_stdout_line_count = 2 git rev-list HEAD --skip=3 &&
36
+ test_stdout_line_count = 0 git rev-list HEAD --skip=5 &&
37
+ test_stdout_line_count = 0 git rev-list HEAD --skip=10
38
'
39
40
test_expect_success '--skip --max-count' '
42
- test $(git rev-list HEAD --skip=0 --max-count=0 | wc -l) = 0 &&
43
- test $(git rev-list HEAD --skip=0 --max-count=10 | wc -l) = 5 &&
44
- test $(git rev-list HEAD --skip=3 --max-count=0 | wc -l) = 0 &&
45
- test $(git rev-list HEAD --skip=3 --max-count=1 | wc -l) = 1 &&
46
- test $(git rev-list HEAD --skip=3 --max-count=2 | wc -l) = 2 &&
47
- test $(git rev-list HEAD --skip=3 --max-count=10 | wc -l) = 2 &&
48
- test $(git rev-list HEAD --skip=5 --max-count=10 | wc -l) = 0 &&
49
- test $(git rev-list HEAD --skip=10 --max-count=10 | wc -l) = 0
41
+ test_stdout_line_count = 0 git rev-list HEAD --skip=0 --max-count=0 &&
42
+ test_stdout_line_count = 5 git rev-list HEAD --skip=0 --max-count=10 &&
43
+ test_stdout_line_count = 0 git rev-list HEAD --skip=3 --max-count=0 &&
44
+ test_stdout_line_count = 1 git rev-list HEAD --skip=3 --max-count=1 &&
45
+ test_stdout_line_count = 2 git rev-list HEAD --skip=3 --max-count=2 &&
46
+ test_stdout_line_count = 2 git rev-list HEAD --skip=3 --max-count=10 &&
47
+ test_stdout_line_count = 0 git rev-list HEAD --skip=5 --max-count=10 &&
48
+ test_stdout_line_count = 0 git rev-list HEAD --skip=10 --max-count=10
49
'
50
51
test_done