* [PATCH] git-grep: Update tests (mainly for -P)
@ 2011-05-22 11:37 Michał Kiedrowicz
2011-05-23 18:57 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Michał Kiedrowicz @ 2011-05-22 11:37 UTC (permalink / raw)
To: Git List; +Cc: Junio C Hamano, Michał Kiedrowicz
This patch adds few more tests to git-grep concerning the
-P/--perl-regexp option.
While at it, add some generic tests for grep.extendedRegexp config
option, for detecting invalid regexep and check if "last one wins" rule
works for selecting regexp type.
Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
---
This is the promised update to tests and is meant to be applied on top of
mk/grep-pcre.
t/t7810-grep.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index e845218..e061108 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -32,6 +32,11 @@ test_expect_success setup '
echo Hello_world
echo HeLLo_world
} >hello_world &&
+ {
+ echo aab
+ echo a+b
+ echo a\\+b
+ } >ab &&
echo vvv >v &&
echo ww w >w &&
echo x x xx x >x &&
@@ -227,7 +232,17 @@ do
git grep --max-depth 0 -n -e vvv $H -- t . >actual &&
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 &&
+ 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 &&
+ test_cmp expected actual
+ '
done
cat >expected <<EOF
@@ -620,6 +635,28 @@ test_expect_success LIBPCRE 'grep -P pattern' '
test_cmp expected actual
'
+test_expect_success 'grep pattern with grep.extendedRegexp=true' '
+ :>empty &&
+ test_must_fail git -c grep.extendedregexp=true \
+ grep "\p{Ps}.*?\p{Pe}" hello.c >actual &&
+ test_cmp empty actual
+'
+
+test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' '
+ git -c grep.extendedregexp=true \
+ grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success LIBPCRE 'grep -P -v pattern' '
+ {
+ echo ab:a+b
+ echo ab:a\\+b
+ } >expected &&
+ git grep -P -v "aab" ab >actual &&
+ test_cmp expected actual
+'
+
test_expect_success LIBPCRE 'grep -P -i pattern' '
{
echo "hello.c: printf(\"Hello world.\n\");"
@@ -637,4 +674,52 @@ test_expect_success LIBPCRE 'grep -P -w pattern' '
test_cmp expected actual
'
+test_expect_success 'grep -G invalidpattern properly dies ' '
+ test_must_fail git grep -G "a["
+'
+
+test_expect_success 'grep -E invalidpattern properly dies ' '
+ test_must_fail git grep -E "a["
+'
+
+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_cmp expected actual
+'
+
+test_expect_success 'grep -E -F -G pattern' '
+ echo ab:aab >expected &&
+ git grep -E -F -G a\\+b >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_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 LIBPCRE 'grep -E -G -F -P pattern' '
+ echo ab:a+b >expected &&
+ git grep -E -G -F -P a\\+b >actual &&
+ test_cmp expected actual
+'
+
test_done
--
1.7.3.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] git-grep: Update tests (mainly for -P)
2011-05-22 11:37 [PATCH] git-grep: Update tests (mainly for -P) Michał Kiedrowicz
@ 2011-05-23 18:57 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2011-05-23 18:57 UTC (permalink / raw)
To: Michał Kiedrowicz; +Cc: Git List
Michał Kiedrowicz <michal.kiedrowicz@gmail.com> writes:
> This patch adds few more tests to git-grep concerning the
> -P/--perl-regexp option.
>
> While at it, add some generic tests for grep.extendedRegexp config
> option, for detecting invalid regexep and check if "last one wins" rule
> works for selecting regexp type.
>
> Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
> ---
> This is the promised update to tests and is meant to be applied on top of
> mk/grep-pcre.
Thanks, will queue.
> t/t7810-grep.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 85 insertions(+), 0 deletions(-)
>
> diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
> index e845218..e061108 100755
> --- a/t/t7810-grep.sh
> +++ b/t/t7810-grep.sh
> @@ -32,6 +32,11 @@ test_expect_success setup '
> echo Hello_world
> echo HeLLo_world
> } >hello_world &&
> + {
> + echo aab
> + echo a+b
> + echo a\\+b
> + } >ab &&
At some point it would be a good idea to clean these up to use either
cascading && or
cat >ab <<\-EOF &&
...
EOF
everywhere.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-23 23:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-22 11:37 [PATCH] git-grep: Update tests (mainly for -P) Michał Kiedrowicz
2011-05-23 18:57 ` 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).