git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michał Kiedrowicz" <michal.kiedrowicz@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Brian Gernhardt" <brian@gernhardtsoftware.com>,
	"Git List" <git@vger.kernel.org>,
	"Michał Kiedrowicz" <michal.kiedrowicz@gmail.com>
Subject: [PATCH] git-grep: Fix problems with recently added tests
Date: Fri, 27 May 2011 00:43:59 +0200	[thread overview]
Message-ID: <1306449839-7491-1-git-send-email-michal.kiedrowicz@gmail.com> (raw)
In-Reply-To: <7vvcwxunbt.fsf@alter.siamese.dyndns.org>

Brian Gernhardt reported that test 'git grep -E -F -G a\\+b' fails on
OS X 10.6.7. This is because I assumed \+ is part of BRE, which isn't
true on all platforms.

The easiest way to make this test pass is to just update expected
output, but that would make the test pointless. Its real purpose is to
check whether 'git grep -E -F -G' is different from 'git grep -E -G -F'.
To check that, let's change pattern to "a+b*c". This should return
different match for -G, -F and -E.

I also made two small tweaks to the tests. First, I added path "ab" to
all calls to future-proof tests. Second, I updated last two tests to
better show that 'git grep -P -E' is different from 'git grep -E -P'.

Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
---
 t/t7810-grep.sh |   56 ++++++++++++++++++++++++------------------------------
 1 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index e061108..e1d8c40 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -33,9 +33,9 @@ test_expect_success setup '
 		echo HeLLo_world
 	} >hello_world &&
 	{
-		echo aab
-		echo a+b
-		echo a\\+b
+		echo "a+b*c"
+		echo "a+bc"
+		echo "abc"
 	} >ab &&
 	echo vvv >v &&
 	echo ww w >w &&
@@ -233,14 +233,14 @@ do
 		test_cmp expected actual
 	'
 	test_expect_success "grep $L with grep.extendedRegexp=false" '
-		echo "ab:a+b" >expected &&
-		git -c grep.extendedRegexp=false grep "a+b" >actual &&
+		echo "ab:a+bc" >expected &&
+		git -c grep.extendedRegexp=false grep "a+b*c" ab >actual &&
 		test_cmp expected actual
 	'
 
 	test_expect_success "grep $L with grep.extendedRegexp=true" '
-		echo "ab:aab" >expected &&
-		git -c grep.extendedRegexp=true grep "a+b" >actual &&
+		echo "ab:abc" >expected &&
+		git -c grep.extendedRegexp=true grep "a+b*c" ab >actual &&
 		test_cmp expected actual
 	'
 done
@@ -650,10 +650,10 @@ test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' '
 
 test_expect_success LIBPCRE 'grep -P -v pattern' '
 	{
-		echo ab:a+b
-		echo ab:a\\+b
+		echo "ab:a+b*c"
+		echo "ab:a+bc"
 	} >expected &&
-	git grep -P -v "aab" ab >actual &&
+	git grep -P -v "abc" ab >actual &&
 	test_cmp expected actual
 '
 
@@ -686,39 +686,33 @@ test_expect_success LIBPCRE 'grep -P invalidpattern properly dies ' '
 	test_must_fail git grep -P "a["
 '
 
-test_expect_success 'grep -F -E -G pattern' '
-	echo ab:a+b >expected &&
-	git grep -F -E -G a+b >actual &&
-	test_cmp expected actual
-'
-
-test_expect_success 'grep -F -G -E pattern' '
-	echo ab:aab >expected &&
-	git grep -F -G -E a+b >actual &&
+test_expect_success 'grep -G -E -F pattern' '
+	echo "ab:a+b*c" >expected &&
+	git grep -G -E -F "a+b*c" ab >actual &&
 	test_cmp expected actual
 '
 
 test_expect_success 'grep -E -F -G pattern' '
-	echo ab:aab >expected &&
-	git grep -E -F -G a\\+b >actual &&
+	echo "ab:a+bc" >expected &&
+	git grep -E -F -G "a+b*c" ab >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'grep -E -G -F pattern' '
-	echo ab:a\\+b >expected &&
-	git grep -E -G -F a\\+b >actual &&
+test_expect_success 'grep -F -G -E pattern' '
+	echo "ab:abc" >expected &&
+	git grep -F -G -E "a+b*c" ab >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success 'grep -G -F -E pattern' '
-	echo ab:a+b >expected &&
-	git grep -G -F -E a\\+b >actual &&
-	test_cmp expected actual
+test_expect_success 'grep -G -F -P -E pattern' '
+	:>empty &&
+	test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual &&
+	test_cmp empty actual
 '
 
-test_expect_success LIBPCRE 'grep -E -G -F -P pattern' '
-	echo ab:a+b >expected &&
-	git grep -E -G -F -P a\\+b >actual &&
+test_expect_success LIBPCRE 'grep -G -F -E -P pattern' '
+	echo "ab:a+b*c" >expected &&
+	git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual &&
 	test_cmp expected actual
 '
 
-- 
1.7.3.4

       reply	other threads:[~2011-05-26 22:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7vvcwxunbt.fsf@alter.siamese.dyndns.org>
2011-05-26 22:43 ` Michał Kiedrowicz [this message]
2011-05-26 21:50 [PATCH] git-grep: Fix problems with recently added tests Michał Kiedrowicz
2011-05-26 21:55 ` Brian Gernhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1306449839-7491-1-git-send-email-michal.kiedrowicz@gmail.com \
    --to=michal.kiedrowicz@gmail.com \
    --cc=brian@gernhardtsoftware.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).