Skip to content

Commit d0042ab

Browse files
mkiedrowiczgitster
authored andcommitted
git-grep: Fix problems with recently added tests
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f556e4a commit d0042ab

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

t/t7810-grep.sh

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ test_expect_success setup '
3333
echo HeLLo_world
3434
} >hello_world &&
3535
{
36-
echo aab
37-
echo a+b
38-
echo a\\+b
36+
echo "a+b*c"
37+
echo "a+bc"
38+
echo "abc"
3939
} >ab &&
4040
echo vvv >v &&
4141
echo ww w >w &&
@@ -233,14 +233,14 @@ do
233233
test_cmp expected actual
234234
'
235235
test_expect_success "grep $L with grep.extendedRegexp=false" '
236-
echo "ab:a+b" >expected &&
237-
git -c grep.extendedRegexp=false grep "a+b" >actual &&
236+
echo "ab:a+bc" >expected &&
237+
git -c grep.extendedRegexp=false grep "a+b*c" ab >actual &&
238238
test_cmp expected actual
239239
'
240240

241241
test_expect_success "grep $L with grep.extendedRegexp=true" '
242-
echo "ab:aab" >expected &&
243-
git -c grep.extendedRegexp=true grep "a+b" >actual &&
242+
echo "ab:abc" >expected &&
243+
git -c grep.extendedRegexp=true grep "a+b*c" ab >actual &&
244244
test_cmp expected actual
245245
'
246246
done
@@ -636,7 +636,7 @@ test_expect_success LIBPCRE 'grep -P pattern' '
636636
'
637637

638638
test_expect_success 'grep pattern with grep.extendedRegexp=true' '
639-
:>empty &&
639+
>empty &&
640640
test_must_fail git -c grep.extendedregexp=true \
641641
grep "\p{Ps}.*?\p{Pe}" hello.c >actual &&
642642
test_cmp empty actual
@@ -650,10 +650,10 @@ test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' '
650650

651651
test_expect_success LIBPCRE 'grep -P -v pattern' '
652652
{
653-
echo ab:a+b
654-
echo ab:a\\+b
653+
echo "ab:a+b*c"
654+
echo "ab:a+bc"
655655
} >expected &&
656-
git grep -P -v "aab" ab >actual &&
656+
git grep -P -v "abc" ab >actual &&
657657
test_cmp expected actual
658658
'
659659

@@ -686,39 +686,33 @@ test_expect_success LIBPCRE 'grep -P invalidpattern properly dies ' '
686686
test_must_fail git grep -P "a["
687687
'
688688

689-
test_expect_success 'grep -F -E -G pattern' '
690-
echo ab:a+b >expected &&
691-
git grep -F -E -G a+b >actual &&
692-
test_cmp expected actual
693-
'
694-
695-
test_expect_success 'grep -F -G -E pattern' '
696-
echo ab:aab >expected &&
697-
git grep -F -G -E a+b >actual &&
689+
test_expect_success 'grep -G -E -F pattern' '
690+
echo "ab:a+b*c" >expected &&
691+
git grep -G -E -F "a+b*c" ab >actual &&
698692
test_cmp expected actual
699693
'
700694

701695
test_expect_success 'grep -E -F -G pattern' '
702-
echo ab:aab >expected &&
703-
git grep -E -F -G a\\+b >actual &&
696+
echo "ab:a+bc" >expected &&
697+
git grep -E -F -G "a+b*c" ab >actual &&
704698
test_cmp expected actual
705699
'
706700

707-
test_expect_success 'grep -E -G -F pattern' '
708-
echo ab:a\\+b >expected &&
709-
git grep -E -G -F a\\+b >actual &&
701+
test_expect_success 'grep -F -G -E pattern' '
702+
echo "ab:abc" >expected &&
703+
git grep -F -G -E "a+b*c" ab >actual &&
710704
test_cmp expected actual
711705
'
712706

713-
test_expect_success 'grep -G -F -E pattern' '
714-
echo ab:a+b >expected &&
715-
git grep -G -F -E a\\+b >actual &&
716-
test_cmp expected actual
707+
test_expect_success 'grep -G -F -P -E pattern' '
708+
>empty &&
709+
test_must_fail git grep -G -F -P -E "a\x{2b}b\x{2a}c" ab >actual &&
710+
test_cmp empty actual
717711
'
718712

719-
test_expect_success LIBPCRE 'grep -E -G -F -P pattern' '
720-
echo ab:a+b >expected &&
721-
git grep -E -G -F -P a\\+b >actual &&
713+
test_expect_success LIBPCRE 'grep -G -F -E -P pattern' '
714+
echo "ab:a+b*c" >expected &&
715+
git grep -G -F -E -P "a\x{2b}b\x{2a}c" ab >actual &&
722716
test_cmp expected actual
723717
'
724718

0 commit comments

Comments
 (0)