mktag tests: parse out options in helper

Change check_verify_failure() helper to parse out options from $@. This makes it easier to add new options in the future. See 06ce79152be (mktag: add a --[no-]strict option, 2021-01-06) for the initial implementation. Let's also replace "" quotes with '' for the test body, the varables we need are eval'd into the body, so there's no need for the quoting confusion. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jun 14, 2021 at 19:28 UTC fce3b089df2edf3a0b3825aef62d243b8a2e0146
1 file changed +31 -12
t/t3800-mktag.sh
+31 -12
@@ -12,15 +12,29 @@ test_description='git mktag: tag object verify test'
12 # given in the expect.pat file.
13
14 check_verify_failure () {
15 - test_expect_success "$1" "
16 - test_must_fail git mktag <tag.sig 2>message &&
17 - grep '$2' message &&
18 - if test '$3' != '--no-strict'
15 + subject=$1 &&
16 + message=$2 &&
17 + shift 2 &&
18 +
19 + no_strict= &&
20 + while test $# != 0
21 + do
22 + case "$1" in
23 + --no-strict)
24 + no_strict=yes
25 + ;;
26 + esac &&
27 + shift
28 + done &&
29 +
30 + test_expect_success "fail with [--[no-]strict]: $subject" '
31 + test_must_fail git mktag <tag.sig 2>err &&
32 + if test -z "$no_strict"
33 then
20 - test_must_fail git mktag --no-strict <tag.sig 2>message.no-strict &&
21 - grep '$2' message.no-strict
34 + test_must_fail git mktag <tag.sig 2>err2 &&
35 + test_cmp err err2
36 fi
23 - "
37 + '
38 }
39
40 test_expect_mktag_success() {
@@ -243,7 +257,8 @@ tagger . <> 0 +0000
257 EOF
258
259 check_verify_failure 'verify tag-name check' \
246 - '^error:.* badTagName:' '--no-strict'
260 + '^error:.* badTagName:' \
261 + --no-strict
262
263 ############################################################
264 # 11. tagger line label check #1
@@ -257,7 +272,8 @@ This is filler
272 EOF
273
274 check_verify_failure '"tagger" line label check #1' \
260 - '^error:.* missingTaggerEntry:' '--no-strict'
275 + '^error:.* missingTaggerEntry:' \
276 + --no-strict
277
278 ############################################################
279 # 12. tagger line label check #2
@@ -272,7 +288,8 @@ This is filler
288 EOF
289
290 check_verify_failure '"tagger" line label check #2' \
275 - '^error:.* missingTaggerEntry:' '--no-strict'
291 + '^error:.* missingTaggerEntry:' \
292 + --no-strict
293
294 ############################################################
295 # 13. allow missing tag author name like fsck
@@ -301,7 +318,8 @@ tagger T A Gger <
318 EOF
319
320 check_verify_failure 'disallow malformed tagger' \
304 - '^error:.* badEmail:' '--no-strict'
321 + '^error:.* badEmail:' \
322 + --no-strict
323
324 ############################################################
325 # 15. allow empty tag email
@@ -425,7 +443,8 @@ this line should not be here
443 EOF
444
445 check_verify_failure 'detect invalid header entry' \
428 - '^error:.* extraHeaderEntry:' '--no-strict'
446 + '^error:.* extraHeaderEntry:' \
447 + --no-strict
448
449 test_expect_success 'invalid header entry config & fsck' '
450 test_must_fail git mktag <tag.sig &&