Skip to content

Commit

Permalink
t/t3800: do not use a temporary file to hold expected result.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Jan 5, 2008
1 parent 0feb4d1 commit e9b2094
Showing 1 changed file with 25 additions and 64 deletions.
89 changes: 25 additions & 64 deletions t/t3800-mktag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ test_description='git-mktag: tag object verify test'
# given in the expect.pat file.

check_verify_failure () {
test_expect_success \
"$1" \
'git-mktag <tag.sig 2>message ||
grep -q -f expect.pat message'
expect="$2"
test_expect_success "$1" '
( ! git-mktag <tag.sig 2>message ) &&
grep -q "$expect" message
'
}

###########################################################
Expand All @@ -33,11 +34,8 @@ cat >tag.sig <<EOF
too short for a tag
EOF

cat >expect.pat <<EOF
^error: .*size wrong.*$
EOF

check_verify_failure 'Tag object length check'
check_verify_failure 'Tag object length check' \
'^error: .*size wrong.*$'

############################################################
# 2. object line label check
Expand All @@ -48,11 +46,7 @@ type tag
tag mytag
EOF

cat >expect.pat <<EOF
^error: char0: .*"object "$
EOF

check_verify_failure '"object" line label check'
check_verify_failure '"object" line label check' '^error: char0: .*"object "$'

############################################################
# 3. object line SHA1 check
Expand All @@ -63,11 +57,7 @@ type tag
tag mytag
EOF

cat >expect.pat <<EOF
^error: char7: .*SHA1 hash$
EOF

check_verify_failure '"object" line SHA1 check'
check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$'

############################################################
# 4. type line label check
Expand All @@ -78,23 +68,15 @@ xxxx tag
tag mytag
EOF

cat >expect.pat <<EOF
^error: char47: .*"[\]ntype "$
EOF

check_verify_failure '"type" line label check'
check_verify_failure '"type" line label check' '^error: char47: .*"\\ntype "$'

############################################################
# 5. type line eol check

echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig

cat >expect.pat <<EOF
^error: char48: .*"[\]n"$
EOF

check_verify_failure '"type" line eol check'
check_verify_failure '"type" line eol check' '^error: char48: .*"\\n"$'

############################################################
# 6. tag line label check #1
Expand All @@ -105,11 +87,8 @@ type tag
xxx mytag
EOF

cat >expect.pat <<EOF
^error: char57: no "tag " found$
EOF

check_verify_failure '"tag" line label check #1'
check_verify_failure '"tag" line label check #1' \
'^error: char57: no "tag " found$'

############################################################
# 7. tag line label check #2
Expand All @@ -120,11 +99,8 @@ type taggggggggggggggggggggggggggggggg
tag
EOF

cat >expect.pat <<EOF
^error: char87: no "tag " found$
EOF

check_verify_failure '"tag" line label check #2'
check_verify_failure '"tag" line label check #2' \
'^error: char87: no "tag " found$'

############################################################
# 8. type line type-name length check
Expand All @@ -135,11 +111,8 @@ type taggggggggggggggggggggggggggggggg
tag mytag
EOF

cat >expect.pat <<EOF
^error: char53: type too long$
EOF

check_verify_failure '"type" line type-name length check'
check_verify_failure '"type" line type-name length check' \
'^error: char53: type too long$'

############################################################
# 9. verify object (SHA1/type) check
Expand All @@ -150,11 +123,8 @@ type tagggg
tag mytag
EOF

cat >expect.pat <<EOF
^error: char7: could not verify object.*$
EOF

check_verify_failure 'verify object (SHA1/type) check'
check_verify_failure 'verify object (SHA1/type) check' \
'^error: char7: could not verify object.*$'

############################################################
# 10. verify tag-name check
Expand All @@ -165,11 +135,8 @@ type commit
tag my tag
EOF

cat >expect.pat <<EOF
^error: char67: could not verify tag name$
EOF

check_verify_failure 'verify tag-name check'
check_verify_failure 'verify tag-name check' \
'^error: char67: could not verify tag name$'

############################################################
# 11. tagger line label check #1
Expand All @@ -180,11 +147,8 @@ type commit
tag mytag
EOF

cat >expect.pat <<EOF
^error: char70: could not find "tagger"$
EOF

check_verify_failure '"tagger" line label check #1'
check_verify_failure '"tagger" line label check #1' \
'^error: char70: could not find "tagger"$'

############################################################
# 12. tagger line label check #2
Expand All @@ -196,11 +160,8 @@ tag mytag
tagger
EOF

cat >expect.pat <<EOF
^error: char70: could not find "tagger"$
EOF

check_verify_failure '"tagger" line label check #2'
check_verify_failure '"tagger" line label check #2' \
'^error: char70: could not find "tagger"$'

############################################################
# 13. create valid tag
Expand Down

0 comments on commit e9b2094

Please sign in to comment.