git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests: grep portability fixes
@ 2008-09-30  8:03 Jeff King
  2008-09-30 10:12 ` Andreas Ericsson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jeff King @ 2008-09-30  8:03 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

We try to avoid using the "-q" or "-e" options, as they are
largely useless, as explained in aadbe44f.

There is one exception for "-e" here, which is in t7701 used
to produce an "or" of patterns. This can be rewritten as an
egrep pattern.

This patch also removes use of "grep -F" in favor of the
more widely available "fgrep".

Signed-off-by: Jeff King <peff@peff.net>
---
These are fallouts from getting (most of) the tests to pass
on Solaris.

 t/t0002-gitfile.sh                     |    4 ++--
 t/t1501-worktree.sh                    |    2 +-
 t/t3700-add.sh                         |    2 +-
 t/t4150-am.sh                          |    2 +-
 t/t6040-tracking-info.sh               |    4 ++--
 t/t7002-grep.sh                        |    2 +-
 t/t7701-repack-unpack-unreachable.sh   |    4 ++--
 t/t9500-gitweb-standalone-no-errors.sh |    2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
index 4db4ac4..cb14425 100755
--- a/t/t0002-gitfile.sh
+++ b/t/t0002-gitfile.sh
@@ -32,7 +32,7 @@ test_expect_success 'bad setup: invalid .git file format' '
 		echo "git rev-parse accepted an invalid .git file"
 		false
 	fi &&
-	if ! grep -qe "Invalid gitfile format" .err
+	if ! grep "Invalid gitfile format" .err
 	then
 		echo "git rev-parse returned wrong error"
 		false
@@ -46,7 +46,7 @@ test_expect_success 'bad setup: invalid .git file path' '
 		echo "git rev-parse accepted an invalid .git file path"
 		false
 	fi &&
-	if ! grep -qe "Not a git repository" .err
+	if ! grep "Not a git repository" .err
 	then
 		echo "git rev-parse returned wrong error"
 		false
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index c039ee3..f6a6f83 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -171,7 +171,7 @@ test_expect_success 'git diff' '
 
 test_expect_success 'git grep' '
 	(cd repo.git/work/sub &&
-	GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep -q dir/tracked)
+	GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep dir/tracked)
 '
 
 test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 2ac93a3..9f6454d 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -226,7 +226,7 @@ test_expect_success 'git add '\''fo\[ou\]bar'\'' ignores foobar' '
 	git reset --hard &&
 	touch fo\[ou\]bar foobar &&
 	git add '\''fo\[ou\]bar'\'' &&
-	git ls-files fo\[ou\]bar | grep -F fo\[ou\]bar &&
+	git ls-files fo\[ou\]bar | fgrep fo\[ou\]bar &&
 	! ( git ls-files foobar | grep foobar )
 '
 
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 1be5fb3..796f795 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -165,7 +165,7 @@ test_expect_success 'am --keep really keeps the subject' '
 	git am --keep patch4 &&
 	! test -d .git/rebase-apply &&
 	git cat-file commit HEAD |
-		grep -q -F "Re: Re: Re: [PATCH 1/5 v2] third"
+		fgrep "Re: Re: Re: [PATCH 1/5 v2] third"
 '
 
 test_expect_success 'am -3 falls back to 3-way merge' '
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index aac212e..ba90601 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -53,7 +53,7 @@ test_expect_success 'checkout' '
 	(
 		cd test && git checkout b1
 	) >actual &&
-	grep -e "have 1 and 1 different" actual
+	grep "have 1 and 1 different" actual
 '
 
 test_expect_success 'status' '
@@ -63,7 +63,7 @@ test_expect_success 'status' '
 		# reports nothing to commit
 		test_must_fail git status
 	) >actual &&
-	grep -e "have 1 and 1 different" actual
+	grep "have 1 and 1 different" actual
 '
 
 
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 5e359cb..18fe6f2 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -109,7 +109,7 @@ do
 	'
 
 	test_expect_success "grep -c $L (no /dev/null)" '
-		! git grep -c test $H | grep -q /dev/null
+		! git grep -c test $H | grep /dev/null
         '
 
 done
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
index 531dac0..b48046e 100755
--- a/t/t7701-repack-unpack-unreachable.sh
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -29,7 +29,7 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
 	git repack -A -d -l &&
 	# verify objects are packed in repository
 	test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
-		   grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
+		   egrep "^($fsha1|$csha1|$tsha1) " |
 		   sort | uniq | wc -l) &&
 	git show $fsha1 &&
 	git show $csha1 &&
@@ -41,7 +41,7 @@ test_expect_success '-A option leaves unreachable objects unpacked' '
 	git repack -A -d -l &&
 	# verify objects are retained unpacked
 	test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
-		   grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
+		   egrep "^($fsha1|$csha1|$tsha1) " |
 		   sort | uniq | wc -l) &&
 	git show $fsha1 &&
 	git show $csha1 &&
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 46ba19b..07117a8 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -56,7 +56,7 @@ gitweb_run () {
 	rm -f gitweb.log &&
 	perl -- "$TEST_DIRECTORY/../gitweb/gitweb.perl" \
 		>/dev/null 2>gitweb.log &&
-	if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
+	if grep "^[[]" gitweb.log >/dev/null 2>&1; then false; else true; fi
 
 	# gitweb.log is left for debugging
 }
-- 
1.6.0.2.517.g4d51

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] tests: grep portability fixes
  2008-09-30  8:03 [PATCH] tests: grep portability fixes Jeff King
@ 2008-09-30 10:12 ` Andreas Ericsson
  2008-09-30 10:29   ` Johannes Sixt
  2008-09-30 10:25 ` Johannes Sixt
  2008-09-30 11:10 ` Mike Ralphson
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Ericsson @ 2008-09-30 10:12 UTC (permalink / raw)
  To: Jeff King; +Cc: Shawn O. Pearce, git

Jeff King wrote:
> We try to avoid using the "-q" or "-e" options, as they are
> largely useless, as explained in aadbe44f.
> 
> There is one exception for "-e" here, which is in t7701 used
> to produce an "or" of patterns. This can be rewritten as an
> egrep pattern.
> 
> This patch also removes use of "grep -F" in favor of the
> more widely available "fgrep".
> 
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> 
> diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
> index 4db4ac4..cb14425 100755
> --- a/t/t0002-gitfile.sh
> +++ b/t/t0002-gitfile.sh
> @@ -32,7 +32,7 @@ test_expect_success 'bad setup: invalid .git file format' '
>  		echo "git rev-parse accepted an invalid .git file"
>  		false
>  	fi &&
> -	if ! grep -qe "Invalid gitfile format" .err
> +	if ! grep "Invalid gitfile format" .err

Doesn't output need to be redirected when you drop '-q'?

Other than that, this looks good after a quick scan.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tests: grep portability fixes
  2008-09-30  8:03 [PATCH] tests: grep portability fixes Jeff King
  2008-09-30 10:12 ` Andreas Ericsson
@ 2008-09-30 10:25 ` Johannes Sixt
  2008-09-30 11:10 ` Mike Ralphson
  2 siblings, 0 replies; 7+ messages in thread
From: Johannes Sixt @ 2008-09-30 10:25 UTC (permalink / raw)
  To: Jeff King; +Cc: Shawn O. Pearce, git

Jeff King schrieb:
> We try to avoid using the "-q" or "-e" options, as they are
> largely useless, as explained in aadbe44f.
> 
> There is one exception for "-e" here, which is in t7701 used
> to produce an "or" of patterns. This can be rewritten as an
> egrep pattern.
> 
> This patch also removes use of "grep -F" in favor of the
> more widely available "fgrep".
> 
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> These are fallouts from getting (most of) the tests to pass
> on Solaris.
> 
>  t/t0002-gitfile.sh                     |    4 ++--
>  t/t1501-worktree.sh                    |    2 +-
>  t/t3700-add.sh                         |    2 +-
>  t/t4150-am.sh                          |    2 +-
>  t/t6040-tracking-info.sh               |    4 ++--
>  t/t7002-grep.sh                        |    2 +-
>  t/t7701-repack-unpack-unreachable.sh   |    4 ++--
>  t/t9500-gitweb-standalone-no-errors.sh |    2 +-
>  8 files changed, 11 insertions(+), 11 deletions(-)

Works here:

Tested-by: Johannes Sixt <johannes.sixt@telecom.at> (MinGW)

-- Hannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tests: grep portability fixes
  2008-09-30 10:12 ` Andreas Ericsson
@ 2008-09-30 10:29   ` Johannes Sixt
  2008-09-30 12:45     ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Sixt @ 2008-09-30 10:29 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: Jeff King, Shawn O. Pearce, git

Andreas Ericsson schrieb:
> Jeff King wrote:
>> -    if ! grep -qe "Invalid gitfile format" .err
>> +    if ! grep "Invalid gitfile format" .err
> 
> Doesn't output need to be redirected when you drop '-q'?

In standard mode, the test output is directed to /dev/null anyway, and in
verbose mode the extra output doesn't hurt at all, and is usually useful
because you know that a pattern matched.

-- Hannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tests: grep portability fixes
  2008-09-30  8:03 [PATCH] tests: grep portability fixes Jeff King
  2008-09-30 10:12 ` Andreas Ericsson
  2008-09-30 10:25 ` Johannes Sixt
@ 2008-09-30 11:10 ` Mike Ralphson
  2008-09-30 12:44   ` Jeff King
  2 siblings, 1 reply; 7+ messages in thread
From: Mike Ralphson @ 2008-09-30 11:10 UTC (permalink / raw)
  To: Jeff King; +Cc: Shawn O. Pearce, git

2008/9/30 Jeff King <peff@peff.net>:
> We try to avoid using the "-q" or "-e" options, as they are
> largely useless, as explained in aadbe44f.
>
> There is one exception for "-e" here, which is in t7701 used
> to produce an "or" of patterns. This can be rewritten as an
> egrep pattern.
>
> This patch also removes use of "grep -F" in favor of the
> more widely available "fgrep".

Works here too (AIX 5.3)

Tested-by: Mike Ralphson <mike@abacus.co.uk>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tests: grep portability fixes
  2008-09-30 11:10 ` Mike Ralphson
@ 2008-09-30 12:44   ` Jeff King
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2008-09-30 12:44 UTC (permalink / raw)
  To: Mike Ralphson; +Cc: Johannes Sixt, Shawn O. Pearce, git

On Tue, Sep 30, 2008 at 12:10:19PM +0100, Mike Ralphson wrote:

> > There is one exception for "-e" here, which is in t7701 used
> > to produce an "or" of patterns. This can be rewritten as an
> > egrep pattern.
> >
> > This patch also removes use of "grep -F" in favor of the
> > more widely available "fgrep".
> 
> Works here too (AIX 5.3)
> 
> Tested-by: Mike Ralphson <mike@abacus.co.uk>

Thanks Mike and Johannes. The dropping of "-e" and "-q" we had done
before, but this was our first use of egrep and fgrep. From my
(admittedly limited) knowledge, I think they are fine, but it is nice to
have some confirmation.

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tests: grep portability fixes
  2008-09-30 10:29   ` Johannes Sixt
@ 2008-09-30 12:45     ` Jeff King
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2008-09-30 12:45 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Andreas Ericsson, Shawn O. Pearce, git

On Tue, Sep 30, 2008 at 12:29:01PM +0200, Johannes Sixt wrote:

> Andreas Ericsson schrieb:
> > Jeff King wrote:
> >> -    if ! grep -qe "Invalid gitfile format" .err
> >> +    if ! grep "Invalid gitfile format" .err
> > 
> > Doesn't output need to be redirected when you drop '-q'?
> 
> In standard mode, the test output is directed to /dev/null anyway, and in
> verbose mode the extra output doesn't hurt at all, and is usually useful
> because you know that a pattern matched.

Exactly. This is the more of the same as aadbe44f (grep portability fix:
don't use "e" or "-q") but I was too lazy to rewrite the justification
completely (but I did reference it).

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-09-30 12:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-30  8:03 [PATCH] tests: grep portability fixes Jeff King
2008-09-30 10:12 ` Andreas Ericsson
2008-09-30 10:29   ` Johannes Sixt
2008-09-30 12:45     ` Jeff King
2008-09-30 10:25 ` Johannes Sixt
2008-09-30 11:10 ` Mike Ralphson
2008-09-30 12:44   ` Jeff King

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).