File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -587,6 +587,11 @@ use these, and "test_set_prereq" for how to define your own.
587
587
Test is not run by root user, and an attempt to write to an
588
588
unwritable file is expected to fail correctly.
589
589
590
+ - LIBPCRE
591
+
592
+ Git was compiled with USE_LIBPCRE=YesPlease. Wrap any tests
593
+ that use git-grep --perl-regexp or git-grep -P in these.
594
+
590
595
Tips for Writing Tests
591
596
----------------------
592
597
Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ test_expect_success setup '
26
26
echo foo mmap bar_mmap
27
27
echo foo_mmap bar mmap baz
28
28
} >file &&
29
+ {
30
+ echo Hello world
31
+ echo HeLLo world
32
+ echo Hello_world
33
+ echo HeLLo_world
34
+ } >hello_world &&
29
35
echo vvv >v &&
30
36
echo ww w >w &&
31
37
echo x x xx x >x &&
@@ -599,4 +605,36 @@ test_expect_success 'grep -e -- -- path' '
599
605
test_cmp expected actual
600
606
'
601
607
608
+ cat > expected << EOF
609
+ hello.c:int main(int argc, const char **argv)
610
+ hello.c: printf("Hello world.\n");
611
+ EOF
612
+
613
+ test_expect_success LIBPCRE ' grep --perl-regexp pattern' '
614
+ git grep --perl-regexp "\p{Ps}.*?\p{Pe}" hello.c >actual &&
615
+ test_cmp expected actual
616
+ '
617
+
618
+ test_expect_success LIBPCRE ' grep -P pattern' '
619
+ git grep -P "\p{Ps}.*?\p{Pe}" hello.c >actual &&
620
+ test_cmp expected actual
621
+ '
622
+
623
+ test_expect_success LIBPCRE ' grep -P -i pattern' '
624
+ {
625
+ echo "hello.c: printf(\"Hello world.\n\");"
626
+ } >expected &&
627
+ git grep -P -i "PRINTF\([^\d]+\)" hello.c >actual &&
628
+ test_cmp expected actual
629
+ '
630
+
631
+ test_expect_success LIBPCRE ' grep -P -w pattern' '
632
+ {
633
+ echo "hello_world:Hello world"
634
+ echo "hello_world:HeLLo world"
635
+ } >expected &&
636
+ git grep -P -w "He((?i)ll)o" hello_world >actual &&
637
+ test_cmp expected actual
638
+ '
639
+
602
640
test_done
Original file line number Diff line number Diff line change @@ -1067,6 +1067,7 @@ esac
1067
1067
1068
1068
test -z " $NO_PERL " && test_set_prereq PERL
1069
1069
test -z " $NO_PYTHON " && test_set_prereq PYTHON
1070
+ test -n " $USE_LIBPCRE " && test_set_prereq LIBPCRE
1070
1071
1071
1072
# Can we rely on git's output in the C locale?
1072
1073
if test -n " $GETTEXT_POISON "
You can’t perform that action at this time.
0 commit comments