1010from pre_commit .util import cmd_output
1111from pre_commit .util import cwd
1212from testing .fixtures import git_dir
13+ from testing .util import xfailif_no_symlink
1314
1415
1516def test_get_root_at_root (tempdir_factory ):
@@ -72,7 +73,6 @@ def get_filenames():
7273 'pre_commit/main.py' ,
7374 'pre_commit/git.py' ,
7475 'im_a_file_that_doesnt_exist.py' ,
75- 'testing/test_symlink' ,
7676 )
7777
7878 return git .get_files_matching (get_filenames )
@@ -84,10 +84,17 @@ def test_get_files_matching_base(get_files_matching_func):
8484 '.pre-commit-hooks.yaml' ,
8585 'pre_commit/main.py' ,
8686 'pre_commit/git.py' ,
87- 'testing/test_symlink'
8887 }
8988
9089
90+ @xfailif_no_symlink
91+ def test_matches_broken_symlink (tmpdir ): # pragma: no cover (non-windwos)
92+ with tmpdir .as_cwd ():
93+ os .symlink ('does-not-exist' , 'link' )
94+ func = git .get_files_matching (lambda : ('link' ,))
95+ assert func ('' , '^$' ) == {'link' }
96+
97+
9198def test_get_files_matching_total_match (get_files_matching_func ):
9299 ret = get_files_matching_func ('^.*\\ .py$' , '^$' )
93100 assert ret == {'pre_commit/main.py' , 'pre_commit/git.py' }
@@ -105,7 +112,7 @@ def test_does_not_include_deleted_fileS(get_files_matching_func):
105112
106113def test_exclude_removes_files (get_files_matching_func ):
107114 ret = get_files_matching_func ('' , '\\ .py$' )
108- assert ret == {'.pre-commit-hooks.yaml' , 'testing/test_symlink' }
115+ assert ret == {'.pre-commit-hooks.yaml' }
109116
110117
111118def resolve_conflict ():
0 commit comments