@@ -226,52 +226,6 @@ def test_output_isatty(tempdir_factory, store):
226226 )
227227
228228
229- def _make_grep_repo (entry , store , args = ()):
230- config = {
231- 'repo' : 'local' ,
232- 'hooks' : [{
233- 'id' : 'grep-hook' ,
234- 'name' : 'grep-hook' ,
235- 'language' : 'pygrep' ,
236- 'entry' : entry ,
237- 'args' : args ,
238- 'types' : ['text' ],
239- }],
240- }
241- return _get_hook (config , store , 'grep-hook' )
242-
243-
244- @pytest .fixture
245- def greppable_files (tmpdir ):
246- with tmpdir .as_cwd ():
247- cmd_output_b ('git' , 'init' , '.' )
248- tmpdir .join ('f1' ).write_binary (b"hello'hi\n world\n " )
249- tmpdir .join ('f2' ).write_binary (b'foo\n bar\n baz\n ' )
250- tmpdir .join ('f3' ).write_binary (b'[WARN] hi\n ' )
251- yield tmpdir
252-
253-
254- def test_grep_hook_matching (greppable_files , store ):
255- hook = _make_grep_repo ('ello' , store )
256- ret , out = _hook_run (hook , ('f1' , 'f2' , 'f3' ), color = False )
257- assert ret == 1
258- assert _norm_out (out ) == b"f1:1:hello'hi\n "
259-
260-
261- def test_grep_hook_case_insensitive (greppable_files , store ):
262- hook = _make_grep_repo ('ELLO' , store , args = ['-i' ])
263- ret , out = _hook_run (hook , ('f1' , 'f2' , 'f3' ), color = False )
264- assert ret == 1
265- assert _norm_out (out ) == b"f1:1:hello'hi\n "
266-
267-
268- @pytest .mark .parametrize ('regex' , ('nope' , "foo'bar" , r'^\[INFO\]' ))
269- def test_grep_hook_not_matching (regex , greppable_files , store ):
270- hook = _make_grep_repo (regex , store )
271- ret , out = _hook_run (hook , ('f1' , 'f2' , 'f3' ), color = False )
272- assert (ret , out ) == (0 , b'' )
273-
274-
275229def _norm_pwd (path ):
276230 # Under windows bash's temp and windows temp is different.
277231 # This normalizes to the bash /tmp
0 commit comments