t6302: simplify non-gpg cases

When commit 618310a taught t6302 to run without the GPG prerequisite, it did so by conditionally creating the signed tags only when gpg is available. As a result, further tests need to take this into account, which they can do with the test_prepare_expect helper. This is a minor hassle, though, as the helper cannot easily cover all cases (it just matches "signed" in the output, so all output must include the actual refname). Instead, let's take a different approach. We'll always create the tags, and only conditionally sign them. This does mean our tag-names are a minor lie, but it lets the tests which do not care about signing easily behave the same in all settings. We'll include a comment to document our lie and avoid confusing further test-writers. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 9, 2016 at 12:49 UTC f30721807f62a33317ae0b48d05af411eb78ee8c
1 file changed +22 -23
t/t6302-for-each-ref-filter.sh
+22 -23
@@ -5,15 +5,6 @@ test_description='test for-each-refs usage of ref-filter APIs'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-gpg.sh
7
8 -test_prepare_expect () {
9 - if test_have_prereq GPG
10 - then
11 - cat
12 - else
13 - sed '/signed/d'
14 - fi
15 -}
16 -
8 test_expect_success 'setup some history and refs' '
9 test_commit one &&
10 test_commit two &&
@@ -22,11 +13,19 @@ test_expect_success 'setup some history and refs' '
13 test_commit four &&
14 git tag -m "An annotated tag" annotated-tag &&
15 git tag -m "Annonated doubly" doubly-annotated-tag annotated-tag &&
16 +
17 + # Note that these "signed" tags might not actually be signed.
18 + # Tests which care about the distinction should be marked
19 + # with the GPG prereq.
20 if test_have_prereq GPG
21 then
27 - git tag -s -m "A signed tag" signed-tag &&
28 - git tag -s -m "Signed doubly" doubly-signed-tag signed-tag
22 + sign=-s
23 + else
24 + sign=
25 fi &&
26 + git tag $sign -m "A signed tag" signed-tag &&
27 + git tag $sign -m "Signed doubly" doubly-signed-tag signed-tag &&
28 +
29 git checkout master &&
30 git update-ref refs/odd/spot master
31 '
@@ -42,7 +41,7 @@ test_expect_success 'filtering with --points-at' '
41 '
42
43 test_expect_success 'check signed tags with --points-at' '
45 - test_prepare_expect <<-\EOF | sed -e "s/Z$//" >expect &&
44 + sed -e "s/Z$//" >expect <<-\EOF &&
45 refs/heads/side Z
46 refs/tags/annotated-tag four
47 refs/tags/four Z
@@ -65,7 +64,7 @@ test_expect_success 'filtering with --merged' '
64 '
65
66 test_expect_success 'filtering with --no-merged' '
68 - test_prepare_expect >expect <<-\EOF &&
67 + cat >expect <<-\EOF &&
68 refs/heads/side
69 refs/tags/annotated-tag
70 refs/tags/doubly-annotated-tag
@@ -78,7 +77,7 @@ test_expect_success 'filtering with --no-merged' '
77 '
78
79 test_expect_success 'filtering with --contains' '
81 - test_prepare_expect >expect <<-\EOF &&
80 + cat >expect <<-\EOF &&
81 refs/heads/master
82 refs/heads/side
83 refs/odd/spot
@@ -99,7 +98,7 @@ test_expect_success '%(color) must fail' '
98 '
99
100 test_expect_success 'left alignment is default' '
102 - test_prepare_expect >expect <<-\EOF &&
101 + cat >expect <<-\EOF &&
102 refname is refs/heads/master |refs/heads/master
103 refname is refs/heads/side |refs/heads/side
104 refname is refs/odd/spot |refs/odd/spot
@@ -117,7 +116,7 @@ test_expect_success 'left alignment is default' '
116 '
117
118 test_expect_success 'middle alignment' '
120 - test_prepare_expect >expect <<-\EOF &&
119 + cat >expect <<-\EOF &&
120 | refname is refs/heads/master |refs/heads/master
121 | refname is refs/heads/side |refs/heads/side
122 | refname is refs/odd/spot |refs/odd/spot
@@ -135,7 +134,7 @@ test_expect_success 'middle alignment' '
134 '
135
136 test_expect_success 'right alignment' '
138 - test_prepare_expect >expect <<-\EOF &&
137 + cat >expect <<-\EOF &&
138 | refname is refs/heads/master|refs/heads/master
139 | refname is refs/heads/side|refs/heads/side
140 | refname is refs/odd/spot|refs/odd/spot
@@ -152,7 +151,7 @@ test_expect_success 'right alignment' '
151 test_cmp expect actual
152 '
153
155 -test_prepare_expect >expect <<-\EOF
154 +cat >expect <<-\EOF
155 | refname is refs/heads/master |refs/heads/master
156 | refname is refs/heads/side |refs/heads/side
157 | refname is refs/odd/spot |refs/odd/spot
@@ -199,7 +198,7 @@ EOF
198 # Individual atoms inside %(align:...) and %(end) must not be quoted.
199
200 test_expect_success 'alignment with format quote' "
202 - test_prepare_expect >expect <<-\EOF &&
201 + cat >expect <<-\EOF &&
202 |' '\''master| A U Thor'\'' '|
203 |' '\''side| A U Thor'\'' '|
204 |' '\''odd/spot| A U Thor'\'' '|
@@ -217,7 +216,7 @@ test_expect_success 'alignment with format quote' "
216 "
217
218 test_expect_success 'nested alignment with quote formatting' "
220 - test_prepare_expect >expect <<-\EOF &&
219 + cat >expect <<-\EOF &&
220 |' master '|
221 |' side '|
222 |' odd/spot '|
@@ -235,7 +234,7 @@ test_expect_success 'nested alignment with quote formatting' "
234 "
235
236 test_expect_success 'check `%(contents:lines=1)`' '
238 - test_prepare_expect >expect <<-\EOF &&
237 + cat >expect <<-\EOF &&
238 master |three
239 side |four
240 odd/spot |three
@@ -253,7 +252,7 @@ test_expect_success 'check `%(contents:lines=1)`' '
252 '
253
254 test_expect_success 'check `%(contents:lines=0)`' '
256 - test_prepare_expect >expect <<-\EOF &&
255 + cat >expect <<-\EOF &&
256 master |
257 side |
258 odd/spot |
@@ -271,7 +270,7 @@ test_expect_success 'check `%(contents:lines=0)`' '
270 '
271
272 test_expect_success 'check `%(contents:lines=99999)`' '
274 - test_prepare_expect >expect <<-\EOF &&
273 + cat >expect <<-\EOF &&
274 master |three
275 side |four
276 odd/spot |three