зеркало из https://github.com/microsoft/git.git
t/t3800: do not use a temporary file to hold expected result.
It is a good practice to write program output to a temporary file during the test, as it would allow easier postmortem when the tested program does break. But there is no benefit in writing the expected output out to the temporary. This actually fixes a bug in check_verify_failure() routine. The intention of the test seems to make sure the "git mktag" command fails, and it spits out the expected error message. But if the command did not fail as expected, the shell function as originally written would not have detected the failure. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
0feb4d1c99
Коммит
e9b20943b7
|
@ -12,10 +12,11 @@ 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 \
|
expect="$2"
|
||||||
"$1" \
|
test_expect_success "$1" '
|
||||||
'git-mktag <tag.sig 2>message ||
|
( ! git-mktag <tag.sig 2>message ) &&
|
||||||
grep -q -f expect.pat message'
|
grep -q "$expect" message
|
||||||
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
|
@ -33,11 +34,8 @@ cat >tag.sig <<EOF
|
||||||
too short for a tag
|
too short for a tag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure 'Tag object length check' \
|
||||||
^error: .*size wrong.*$
|
'^error: .*size wrong.*$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure 'Tag object length check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 2. object line label check
|
# 2. object line label check
|
||||||
|
@ -48,11 +46,7 @@ type tag
|
||||||
tag mytag
|
tag mytag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"object" line label check' '^error: char0: .*"object "$'
|
||||||
^error: char0: .*"object "$
|
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"object" line label check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 3. object line SHA1 check
|
# 3. object line SHA1 check
|
||||||
|
@ -63,11 +57,7 @@ type tag
|
||||||
tag mytag
|
tag mytag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$'
|
||||||
^error: char7: .*SHA1 hash$
|
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"object" line SHA1 check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 4. type line label check
|
# 4. type line label check
|
||||||
|
@ -78,11 +68,7 @@ xxxx tag
|
||||||
tag mytag
|
tag mytag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"type" line label check' '^error: char47: .*"\\ntype "$'
|
||||||
^error: char47: .*"[\]ntype "$
|
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"type" line label check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 5. type line eol check
|
# 5. type line eol check
|
||||||
|
@ -90,11 +76,7 @@ check_verify_failure '"type" line label check'
|
||||||
echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
|
echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
|
||||||
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
|
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"type" line eol check' '^error: char48: .*"\\n"$'
|
||||||
^error: char48: .*"[\]n"$
|
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"type" line eol check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 6. tag line label check #1
|
# 6. tag line label check #1
|
||||||
|
@ -105,11 +87,8 @@ type tag
|
||||||
xxx mytag
|
xxx mytag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"tag" line label check #1' \
|
||||||
^error: char57: no "tag " found$
|
'^error: char57: no "tag " found$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"tag" line label check #1'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 7. tag line label check #2
|
# 7. tag line label check #2
|
||||||
|
@ -120,11 +99,8 @@ type taggggggggggggggggggggggggggggggg
|
||||||
tag
|
tag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"tag" line label check #2' \
|
||||||
^error: char87: no "tag " found$
|
'^error: char87: no "tag " found$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"tag" line label check #2'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 8. type line type-name length check
|
# 8. type line type-name length check
|
||||||
|
@ -135,11 +111,8 @@ type taggggggggggggggggggggggggggggggg
|
||||||
tag mytag
|
tag mytag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"type" line type-name length check' \
|
||||||
^error: char53: type too long$
|
'^error: char53: type too long$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"type" line type-name length check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 9. verify object (SHA1/type) check
|
# 9. verify object (SHA1/type) check
|
||||||
|
@ -150,11 +123,8 @@ type tagggg
|
||||||
tag mytag
|
tag mytag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure 'verify object (SHA1/type) check' \
|
||||||
^error: char7: could not verify object.*$
|
'^error: char7: could not verify object.*$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure 'verify object (SHA1/type) check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 10. verify tag-name check
|
# 10. verify tag-name check
|
||||||
|
@ -165,11 +135,8 @@ type commit
|
||||||
tag my tag
|
tag my tag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure 'verify tag-name check' \
|
||||||
^error: char67: could not verify tag name$
|
'^error: char67: could not verify tag name$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure 'verify tag-name check'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 11. tagger line label check #1
|
# 11. tagger line label check #1
|
||||||
|
@ -180,11 +147,8 @@ type commit
|
||||||
tag mytag
|
tag mytag
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"tagger" line label check #1' \
|
||||||
^error: char70: could not find "tagger"$
|
'^error: char70: could not find "tagger"$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"tagger" line label check #1'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 12. tagger line label check #2
|
# 12. tagger line label check #2
|
||||||
|
@ -196,11 +160,8 @@ tag mytag
|
||||||
tagger
|
tagger
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >expect.pat <<EOF
|
check_verify_failure '"tagger" line label check #2' \
|
||||||
^error: char70: could not find "tagger"$
|
'^error: char70: could not find "tagger"$'
|
||||||
EOF
|
|
||||||
|
|
||||||
check_verify_failure '"tagger" line label check #2'
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# 13. create valid tag
|
# 13. create valid tag
|
||||||
|
|
Загрузка…
Ссылка в новой задаче