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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Mar 22, 2014 at 18:15 UTC b0f7c7cf865e6b14ccf90f34b6fde0d08af6b50b
1 file changed +25 -39
t/t4209-log-pickaxe.sh
+25 -39
@@ -4,80 +4,74 @@ test_description='log --grep/--author/--regexp-ignore-case/-S/-G'
4 . ./test-lib.sh
5
6 test_expect_success setup '
7 + >expect_nomatch &&
8 +
9 >file &&
10 git add file &&
11 test_tick &&
12 git commit -m initial &&
13 + git rev-parse --verify HEAD >expect_initial &&
14
15 echo Picked >file &&
16 + git add file &&
17 test_tick &&
14 - git commit -a --author="Another Person <another@example.com>" -m second
18 + git commit --author="Another Person <another@example.com>" -m second &&
19 + git rev-parse --verify HEAD >expect_second
20 '
21
22 test_expect_success 'log --grep' '
23 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
25 '
26
27 test_expect_success 'log --grep --regexp-ignore-case' '
28 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
30 '
31
32 test_expect_success 'log --grep -i' '
33 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
35 '
36
37 test_expect_success 'log --author --regexp-ignore-case' '
38 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
40 '
41
42 test_expect_success 'log --author -i' '
43 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
45 '
46
47 test_expect_success 'log -G (nomatch)' '
48 git log -Gpicked --format=%H >actual &&
49 - >expect &&
50 - test_cmp expect actual
49 + test_cmp expect_nomatch actual
50 '
51
52 test_expect_success 'log -G (match)' '
53 git log -GPicked --format=%H >actual &&
55 - git rev-parse --verify HEAD >expect &&
56 - test_cmp expect actual
54 + test_cmp expect_second actual
55 '
56
57 test_expect_success 'log -G --regexp-ignore-case (nomatch)' '
58 git log --regexp-ignore-case -Gpickle --format=%H >actual &&
61 - >expect &&
62 - test_cmp expect actual
59 + test_cmp expect_nomatch actual
60 '
61
62 test_expect_success 'log -G -i (nomatch)' '
63 git log -i -Gpickle --format=%H >actual &&
67 - >expect &&
68 - test_cmp expect actual
64 + test_cmp expect_nomatch actual
65 '
66
67 test_expect_success 'log -G --regexp-ignore-case (match)' '
68 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
70 '
71
72 test_expect_success 'log -G -i (match)' '
73 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
75 '
76
77 test_expect_success 'log -G --textconv (missing textconv tool)' '
@@ -89,45 +83,38 @@ test_expect_success 'log -G --textconv (missing textconv tool)' '
83 test_expect_success 'log -G --no-textconv (missing textconv tool)' '
84 echo "* diff=test" >.gitattributes &&
85 git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
92 - >expect &&
93 - test_cmp expect actual &&
86 + test_cmp expect_nomatch actual &&
87 rm .gitattributes
88 '
89
90 test_expect_success 'log -S (nomatch)' '
91 git log -Spicked --format=%H >actual &&
99 - >expect &&
100 - test_cmp expect actual
92 + test_cmp expect_nomatch actual
93 '
94
95 test_expect_success 'log -S (match)' '
96 git log -SPicked --format=%H >actual &&
105 - git rev-parse --verify HEAD >expect &&
106 - test_cmp expect actual
97 + test_cmp expect_second actual
98 '
99
100 test_expect_success 'log -S --regexp-ignore-case (match)' '
101 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
103 '
104
105 test_expect_success 'log -S -i (match)' '
106 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
108 '
109
110 test_expect_success 'log -S --regexp-ignore-case (nomatch)' '
111 git log --regexp-ignore-case -Spickle --format=%H >actual &&
123 - >expect &&
124 - test_cmp expect actual
112 + test_cmp expect_nomatch actual
113 '
114
115 test_expect_success 'log -S -i (nomatch)' '
116 git log -i -Spickle --format=%H >actual &&
129 - >expect &&
130 - test_cmp expect actual
117 + test_cmp expect_nomatch actual
118 '
119
120 test_expect_success 'log -S --textconv (missing textconv tool)' '
@@ -139,8 +126,7 @@ test_expect_success 'log -S --textconv (missing textconv tool)' '
126 test_expect_success 'log -S --no-textconv (missing textconv tool)' '
127 echo "* diff=test" >.gitattributes &&
128 git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
142 - >expect &&
143 - test_cmp expect actual &&
129 + test_cmp expect_nomatch actual &&
130 rm .gitattributes
131 '
132