list-objects-filter: don't memset after releasing filter struct
[git/debian.git] / t / t7812-grep-icase-non-ascii.sh
blobac7be5471452a0a8b2123dc39be80caf3520e9db
1 #!/bin/sh
3 test_description='grep icase on non-English locales'
5 . ./lib-gettext.sh
7 doalarm () {
8 perl -e 'alarm shift; exec @ARGV' -- "$@"
11 test_expect_success GETTEXT_LOCALE 'setup' '
12 test_write_lines "TILRAUN: Halló Heimur!" >file &&
13 git add file &&
14 LC_ALL="$is_IS_locale" &&
15 export LC_ALL
18 test_expect_success GETTEXT_LOCALE 'setup REGEX_LOCALE prerequisite' '
19 # This "test-tool" invocation is identical...
20 if test-tool regex "HALLÓ" "Halló" ICASE
21 then
22 test_set_prereq REGEX_LOCALE
23 else
25 # ... to this one, but this way "test_must_fail" will
26 # tell a segfault or abort() from the regexec() test
27 # itself
28 test_must_fail test-tool regex "HALLÓ" "Halló" ICASE
32 test_expect_success REGEX_LOCALE 'grep literal string, no -F' '
33 git grep -i "TILRAUN: Halló Heimur!" &&
34 git grep -i "TILRAUN: HALLÓ HEIMUR!"
37 test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 icase' '
38 git grep --perl-regexp "TILRAUN: H.lló Heimur!" &&
39 git grep --perl-regexp -i "TILRAUN: H.lló Heimur!" &&
40 git grep --perl-regexp -i "TILRAUN: H.LLÓ HEIMUR!"
43 test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 string with "+"' '
44 test_write_lines "TILRAUN: Hallóó Heimur!" >file2 &&
45 git add file2 &&
46 git grep -l --perl-regexp "TILRAUN: H.lló+ Heimur!" >actual &&
47 echo file >expected &&
48 echo file2 >>expected &&
49 test_cmp expected actual
52 test_expect_success REGEX_LOCALE 'grep literal string, with -F' '
53 git grep -i -F "TILRAUN: Halló Heimur!" &&
54 git grep -i -F "TILRAUN: HALLÓ HEIMUR!"
57 test_expect_success REGEX_LOCALE 'grep string with regex, with -F' '
58 test_write_lines "TILRAUN: Halló Heimur [abc]!" >file3 &&
59 git add file3 &&
60 git grep -i -F "TILRAUN: Halló Heimur [abc]!" file3
63 test_expect_success REGEX_LOCALE 'pickaxe -i on non-ascii' '
64 git commit -m first &&
65 git log --format=%f -i -S"TILRAUN: HALLÓ HEIMUR!" >actual &&
66 echo first >expected &&
67 test_cmp expected actual
70 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: setup invalid UTF-8 data' '
71 printf "\\200\\n" >invalid-0x80 &&
72 echo "ævar" >expected &&
73 cat expected >>invalid-0x80 &&
74 git add invalid-0x80 &&
76 # Test for PCRE2_MATCH_INVALID_UTF bug
77 # https://bugs.exim.org/show_bug.cgi?id=2642
78 printf "\\345Aæ\\n" >invalid-0xe5 &&
79 git add invalid-0xe5
82 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data' '
83 git grep -h "var" invalid-0x80 >actual &&
84 test_cmp expected actual &&
85 git grep -h "(*NO_JIT)var" invalid-0x80 >actual &&
86 test_cmp expected actual
89 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
90 git grep -h "Aæ" invalid-0xe5 >actual &&
91 test_cmp invalid-0xe5 actual &&
92 git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
93 test_cmp invalid-0xe5 actual
96 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data' '
97 git grep -h "æ" invalid-0x80 >actual &&
98 test_cmp expected actual &&
99 git grep -h "(*NO_JIT)æ" invalid-0x80 >actual &&
100 test_cmp expected actual
103 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data (PCRE2 bug #2642)' '
104 git grep -h "Aæ" invalid-0xe5 >actual &&
105 test_cmp invalid-0xe5 actual &&
106 git grep -h "(*NO_JIT)Aæ" invalid-0xe5 >actual &&
107 test_cmp invalid-0xe5 actual
110 test_lazy_prereq PCRE2_MATCH_INVALID_UTF '
111 test-tool pcre2-config has-PCRE2_MATCH_INVALID_UTF
114 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
115 test_might_fail git grep -hi "Æ" invalid-0x80 >actual &&
116 test_might_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual
119 test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' '
120 git grep -hi "Æ" invalid-0x80 >actual &&
121 test_cmp expected actual &&
122 git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual &&
123 test_cmp expected actual
126 test_expect_success GETTEXT_LOCALE,LIBPCRE2,PCRE2_MATCH_INVALID_UTF 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i (PCRE2 bug #2642)' '
127 git grep -hi "Æ" invalid-0xe5 >actual &&
128 test_cmp invalid-0xe5 actual &&
129 git grep -hi "(*NO_JIT)Æ" invalid-0xe5 >actual &&
130 test_cmp invalid-0xe5 actual &&
132 # Only the case of grepping the ASCII part in a way that
133 # relies on -i fails
134 git grep -hi "aÆ" invalid-0xe5 >actual &&
135 test_cmp invalid-0xe5 actual &&
136 git grep -hi "(*NO_JIT)aÆ" invalid-0xe5 >actual &&
137 test_cmp invalid-0xe5 actual
140 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-literal ASCII from UTF-8' '
141 git grep --perl-regexp -h -o -e ll. file >actual &&
142 echo "lló" >expected &&
143 test_cmp expected actual
146 test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep avoid endless loop bug' '
147 echo " Halló" >leading-whitespace &&
148 git add leading-whitespace &&
149 doalarm 1 git grep --perl-regexp "^\s" leading-whitespace
152 test_done