Skip to content

Commit fce3b08

Browse files
avargitster
authored andcommitted
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 06ce791 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 670b81a commit fce3b08

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

t/t3800-mktag.sh

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,29 @@ test_description='git mktag: tag object verify test'
1212
# given in the expect.pat file.
1313

1414
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"
1933
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
2236
fi
23-
"
37+
'
2438
}
2539

2640
test_expect_mktag_success() {
@@ -243,7 +257,8 @@ tagger . <> 0 +0000
243257
EOF
244258

245259
check_verify_failure 'verify tag-name check' \
246-
'^error:.* badTagName:' '--no-strict'
260+
'^error:.* badTagName:' \
261+
--no-strict
247262

248263
############################################################
249264
# 11. tagger line label check #1
@@ -257,7 +272,8 @@ This is filler
257272
EOF
258273

259274
check_verify_failure '"tagger" line label check #1' \
260-
'^error:.* missingTaggerEntry:' '--no-strict'
275+
'^error:.* missingTaggerEntry:' \
276+
--no-strict
261277

262278
############################################################
263279
# 12. tagger line label check #2
@@ -272,7 +288,8 @@ This is filler
272288
EOF
273289

274290
check_verify_failure '"tagger" line label check #2' \
275-
'^error:.* missingTaggerEntry:' '--no-strict'
291+
'^error:.* missingTaggerEntry:' \
292+
--no-strict
276293

277294
############################################################
278295
# 13. allow missing tag author name like fsck
@@ -301,7 +318,8 @@ tagger T A Gger <
301318
EOF
302319

303320
check_verify_failure 'disallow malformed tagger' \
304-
'^error:.* badEmail:' '--no-strict'
321+
'^error:.* badEmail:' \
322+
--no-strict
305323

306324
############################################################
307325
# 15. allow empty tag email
@@ -425,7 +443,8 @@ this line should not be here
425443
EOF
426444

427445
check_verify_failure 'detect invalid header entry' \
428-
'^error:.* extraHeaderEntry:' '--no-strict'
446+
'^error:.* extraHeaderEntry:' \
447+
--no-strict
429448

430449
test_expect_success 'invalid header entry config & fsck' '
431450
test_must_fail git mktag <tag.sig &&

0 commit comments

Comments
 (0)