* [PATCH] t/t3800: do not use a temporary file to hold expected result.
[not found] <1199506008-12225-1-git-send-email-vmiklos@frugalware.org>
@ 2008-01-05 6:48 ` Junio C Hamano
2008-01-05 6:50 ` [PATCH] t/t7600: avoid GNUism in grep Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2008-01-05 6:48 UTC (permalink / raw)
To: Miklos Vajna; +Cc: git
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>
---
t/t3800-mktag.sh | 89 +++++++++++++++--------------------------------------
1 files changed, 25 insertions(+), 64 deletions(-)
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index e5f3073..f280320 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -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 ||
- egrep -q -f expect.pat message'
+ expect="$2"
+ test_expect_success "$1" '
+ ( ! git-mktag <tag.sig 2>message ) &&
+ grep -q "$expect" message
+ '
}
###########################################################
@@ -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
@@ -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
@@ -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
@@ -78,11 +68,7 @@ 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
@@ -90,11 +76,7 @@ check_verify_failure '"type" line label 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
--
1.5.4.rc2.17.g257f
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] t/t7600: avoid GNUism in grep
[not found] <1199506008-12225-1-git-send-email-vmiklos@frugalware.org>
2008-01-05 6:48 ` [PATCH] t/t3800: do not use a temporary file to hold expected result Junio C Hamano
@ 2008-01-05 6:50 ` Junio C Hamano
2008-01-05 7:14 ` Charles Bailey
1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2008-01-05 6:50 UTC (permalink / raw)
To: Miklos Vajna; +Cc: git
Using \+ to mean "one or more" in grep without -E is a GNU
extension outside POSIX. Avoid it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* I do not think these clean-ups are particularly necessary
right now, but as we noticed it why not...
t/t7600-merge.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 6424c6e..21862ac 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -371,7 +371,7 @@ test_expect_success 'override config option -n' '
git merge --summary c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
verify_parents $c1 $c2 &&
- if ! grep -e "^ file | \+2 +-$" diffstat.txt
+ if ! grep -e "^ file | *2 +-$" diffstat.txt
then
echo "[OOPS] diffstat was not generated"
fi
@@ -386,7 +386,7 @@ test_expect_success 'override config option --summary' '
git merge -n c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
verify_parents $c1 $c2 &&
- if grep -e "^ file | \+2 +-$" diffstat.txt
+ if grep -e "^ file | +2 +-$" diffstat.txt
then
echo "[OOPS] diffstat was generated"
false
--
1.5.4.rc2.17.g257f
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] t/t7600: avoid GNUism in grep
2008-01-05 6:50 ` [PATCH] t/t7600: avoid GNUism in grep Junio C Hamano
@ 2008-01-05 7:14 ` Charles Bailey
2008-01-05 8:02 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Charles Bailey @ 2008-01-05 7:14 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Miklos Vajna, git
Junio C Hamano wrote:
> diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
> index 6424c6e..21862ac 100755
> --- a/t/t7600-merge.sh
> +++ b/t/t7600-merge.sh
> @@ -371,7 +371,7 @@ test_expect_success 'override config option -n' '
> git merge --summary c2 >diffstat.txt &&
> verify_merge file result.1-5 msg.1-5 &&
> verify_parents $c1 $c2 &&
> - if ! grep -e "^ file | \+2 +-$" diffstat.txt
> + if ! grep -e "^ file | *2 +-$" diffstat.txt
> then
> echo "[OOPS] diffstat was not generated"
> fi
> @@ -386,7 +386,7 @@ test_expect_success 'override config option --summary' '
> git merge -n c2 >diffstat.txt &&
> verify_merge file result.1-5 msg.1-5 &&
> verify_parents $c1 $c2 &&
> - if grep -e "^ file | \+2 +-$" diffstat.txt
> + if grep -e "^ file | +2 +-$" diffstat.txt
> then
> echo "[OOPS] diffstat was generated"
> false
I'm not sure that you quite made the change you meant to change in the
second chunk ( ' +' vs. ' *' ? ).
Charles.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] t/t7600: avoid GNUism in grep
2008-01-05 7:14 ` Charles Bailey
@ 2008-01-05 8:02 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2008-01-05 8:02 UTC (permalink / raw)
To: Charles Bailey; +Cc: Miklos Vajna, git
Thanks. Embarrasing.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-05 8:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1199506008-12225-1-git-send-email-vmiklos@frugalware.org>
2008-01-05 6:48 ` [PATCH] t/t3800: do not use a temporary file to hold expected result Junio C Hamano
2008-01-05 6:50 ` [PATCH] t/t7600: avoid GNUism in grep Junio C Hamano
2008-01-05 7:14 ` Charles Bailey
2008-01-05 8:02 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).