Skip to content

Commit b0f7c7c

Browse files
rscharfegitster
authored andcommitted
t4209: set up expectations up front
Instead of creating an expect file for each test, build three files with the possible valid values during setup and use them in the tests. This shortens the test code and saves nine calls to git rev-parse. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f95c9f commit b0f7c7c

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

t/t4209-log-pickaxe.sh

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,74 @@ test_description='log --grep/--author/--regexp-ignore-case/-S/-G'
44
. ./test-lib.sh
55

66
test_expect_success setup '
7+
>expect_nomatch &&
8+
79
>file &&
810
git add file &&
911
test_tick &&
1012
git commit -m initial &&
13+
git rev-parse --verify HEAD >expect_initial &&
1114
1215
echo Picked >file &&
16+
git add file &&
1317
test_tick &&
14-
git commit -a --author="Another Person <[email protected]>" -m second
18+
git commit --author="Another Person <[email protected]>" -m second &&
19+
git rev-parse --verify HEAD >expect_second
1520
'
1621

1722
test_expect_success 'log --grep' '
1823
git log --grep=initial --format=%H >actual &&
19-
git rev-parse --verify HEAD^ >expect &&
20-
test_cmp expect actual
24+
test_cmp expect_initial actual
2125
'
2226

2327
test_expect_success 'log --grep --regexp-ignore-case' '
2428
git log --regexp-ignore-case --grep=InItial --format=%H >actual &&
25-
git rev-parse --verify HEAD^ >expect &&
26-
test_cmp expect actual
29+
test_cmp expect_initial actual
2730
'
2831

2932
test_expect_success 'log --grep -i' '
3033
git log -i --grep=InItial --format=%H >actual &&
31-
git rev-parse --verify HEAD^ >expect &&
32-
test_cmp expect actual
34+
test_cmp expect_initial actual
3335
'
3436

3537
test_expect_success 'log --author --regexp-ignore-case' '
3638
git log --regexp-ignore-case --author=person --format=%H >actual &&
37-
git rev-parse --verify HEAD >expect &&
38-
test_cmp expect actual
39+
test_cmp expect_second actual
3940
'
4041

4142
test_expect_success 'log --author -i' '
4243
git log -i --author=person --format=%H >actual &&
43-
git rev-parse --verify HEAD >expect &&
44-
test_cmp expect actual
44+
test_cmp expect_second actual
4545
'
4646

4747
test_expect_success 'log -G (nomatch)' '
4848
git log -Gpicked --format=%H >actual &&
49-
>expect &&
50-
test_cmp expect actual
49+
test_cmp expect_nomatch actual
5150
'
5251

5352
test_expect_success 'log -G (match)' '
5453
git log -GPicked --format=%H >actual &&
55-
git rev-parse --verify HEAD >expect &&
56-
test_cmp expect actual
54+
test_cmp expect_second actual
5755
'
5856

5957
test_expect_success 'log -G --regexp-ignore-case (nomatch)' '
6058
git log --regexp-ignore-case -Gpickle --format=%H >actual &&
61-
>expect &&
62-
test_cmp expect actual
59+
test_cmp expect_nomatch actual
6360
'
6461

6562
test_expect_success 'log -G -i (nomatch)' '
6663
git log -i -Gpickle --format=%H >actual &&
67-
>expect &&
68-
test_cmp expect actual
64+
test_cmp expect_nomatch actual
6965
'
7066

7167
test_expect_success 'log -G --regexp-ignore-case (match)' '
7268
git log --regexp-ignore-case -Gpicked --format=%H >actual &&
73-
git rev-parse --verify HEAD >expect &&
74-
test_cmp expect actual
69+
test_cmp expect_second actual
7570
'
7671

7772
test_expect_success 'log -G -i (match)' '
7873
git log -i -Gpicked --format=%H >actual &&
79-
git rev-parse --verify HEAD >expect &&
80-
test_cmp expect actual
74+
test_cmp expect_second actual
8175
'
8276

8377
test_expect_success 'log -G --textconv (missing textconv tool)' '
@@ -89,45 +83,38 @@ test_expect_success 'log -G --textconv (missing textconv tool)' '
8983
test_expect_success 'log -G --no-textconv (missing textconv tool)' '
9084
echo "* diff=test" >.gitattributes &&
9185
git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
92-
>expect &&
93-
test_cmp expect actual &&
86+
test_cmp expect_nomatch actual &&
9487
rm .gitattributes
9588
'
9689

9790
test_expect_success 'log -S (nomatch)' '
9891
git log -Spicked --format=%H >actual &&
99-
>expect &&
100-
test_cmp expect actual
92+
test_cmp expect_nomatch actual
10193
'
10294

10395
test_expect_success 'log -S (match)' '
10496
git log -SPicked --format=%H >actual &&
105-
git rev-parse --verify HEAD >expect &&
106-
test_cmp expect actual
97+
test_cmp expect_second actual
10798
'
10899

109100
test_expect_success 'log -S --regexp-ignore-case (match)' '
110101
git log --regexp-ignore-case -Spicked --format=%H >actual &&
111-
git rev-parse --verify HEAD >expect &&
112-
test_cmp expect actual
102+
test_cmp expect_second actual
113103
'
114104

115105
test_expect_success 'log -S -i (match)' '
116106
git log -i -Spicked --format=%H >actual &&
117-
git rev-parse --verify HEAD >expect &&
118-
test_cmp expect actual
107+
test_cmp expect_second actual
119108
'
120109

121110
test_expect_success 'log -S --regexp-ignore-case (nomatch)' '
122111
git log --regexp-ignore-case -Spickle --format=%H >actual &&
123-
>expect &&
124-
test_cmp expect actual
112+
test_cmp expect_nomatch actual
125113
'
126114

127115
test_expect_success 'log -S -i (nomatch)' '
128116
git log -i -Spickle --format=%H >actual &&
129-
>expect &&
130-
test_cmp expect actual
117+
test_cmp expect_nomatch actual
131118
'
132119

133120
test_expect_success 'log -S --textconv (missing textconv tool)' '
@@ -139,8 +126,7 @@ test_expect_success 'log -S --textconv (missing textconv tool)' '
139126
test_expect_success 'log -S --no-textconv (missing textconv tool)' '
140127
echo "* diff=test" >.gitattributes &&
141128
git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
142-
>expect &&
143-
test_cmp expect actual &&
129+
test_cmp expect_nomatch actual &&
144130
rm .gitattributes
145131
'
146132

0 commit comments

Comments
 (0)