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
06ce79152b (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>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2021-06-14 19:28:18 +02:00 committed by Junio C Hamano
parent 670b81a890
commit fce3b089df

View File

@ -12,15 +12,29 @@ test_description='git mktag: tag object verify test'
# given in the expect.pat file. # given in the expect.pat file.
check_verify_failure () { check_verify_failure () {
test_expect_success "$1" " subject=$1 &&
test_must_fail git mktag <tag.sig 2>message && message=$2 &&
grep '$2' message && shift 2 &&
if test '$3' != '--no-strict'
no_strict= &&
while test $# != 0
do
case "$1" in
--no-strict)
no_strict=yes
;;
esac &&
shift
done &&
test_expect_success "fail with [--[no-]strict]: $subject" '
test_must_fail git mktag <tag.sig 2>err &&
if test -z "$no_strict"
then then
test_must_fail git mktag --no-strict <tag.sig 2>message.no-strict && test_must_fail git mktag <tag.sig 2>err2 &&
grep '$2' message.no-strict test_cmp err err2
fi fi
" '
} }
test_expect_mktag_success() { test_expect_mktag_success() {
@ -243,7 +257,8 @@ tagger . <> 0 +0000
EOF EOF
check_verify_failure 'verify tag-name check' \ check_verify_failure 'verify tag-name check' \
'^error:.* badTagName:' '--no-strict' '^error:.* badTagName:' \
--no-strict
############################################################ ############################################################
# 11. tagger line label check #1 # 11. tagger line label check #1
@ -257,7 +272,8 @@ This is filler
EOF EOF
check_verify_failure '"tagger" line label check #1' \ check_verify_failure '"tagger" line label check #1' \
'^error:.* missingTaggerEntry:' '--no-strict' '^error:.* missingTaggerEntry:' \
--no-strict
############################################################ ############################################################
# 12. tagger line label check #2 # 12. tagger line label check #2
@ -272,7 +288,8 @@ This is filler
EOF EOF
check_verify_failure '"tagger" line label check #2' \ check_verify_failure '"tagger" line label check #2' \
'^error:.* missingTaggerEntry:' '--no-strict' '^error:.* missingTaggerEntry:' \
--no-strict
############################################################ ############################################################
# 13. allow missing tag author name like fsck # 13. allow missing tag author name like fsck
@ -301,7 +318,8 @@ tagger T A Gger <
EOF EOF
check_verify_failure 'disallow malformed tagger' \ check_verify_failure 'disallow malformed tagger' \
'^error:.* badEmail:' '--no-strict' '^error:.* badEmail:' \
--no-strict
############################################################ ############################################################
# 15. allow empty tag email # 15. allow empty tag email
@ -425,7 +443,8 @@ this line should not be here
EOF EOF
check_verify_failure 'detect invalid header entry' \ check_verify_failure 'detect invalid header entry' \
'^error:.* extraHeaderEntry:' '--no-strict' '^error:.* extraHeaderEntry:' \
--no-strict
test_expect_success 'invalid header entry config & fsck' ' test_expect_success 'invalid header entry config & fsck' '
test_must_fail git mktag <tag.sig && test_must_fail git mktag <tag.sig &&