summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a80dff2)
raw | patch | inline | side by side (parent: a80dff2)
author | Michał Kiedrowicz <michal.kiedrowicz@gmail.com> | |
Sun, 22 May 2011 11:37:28 +0000 (13:37 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 23 May 2011 18:57:08 +0000 (11:57 -0700) |
Add few more tests for "-P/--perl-regexp" option of "git grep".
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7810-grep.sh | patch | blob | history |
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index e845218f67a4d14160900884bb0b0d9c8785ba97..e061108a6439e23c201d728aba8dd4ad74d54fe4 100755 (executable)
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
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 &&
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
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\");"
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