Skip to content

Commit f33a254

Browse files
authored
Merge pull request pre-commit#552 from pre-commit/more_directed_symlink_test
More specific symlink testing without checking in a symlink
2 parents 44b2af8 + 096f906 commit f33a254

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

testing/test_symlink

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/git_test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pre_commit.util import cmd_output
1111
from pre_commit.util import cwd
1212
from testing.fixtures import git_dir
13+
from testing.util import xfailif_no_symlink
1314

1415

1516
def 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+
9198
def 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

106113
def 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

111118
def resolve_conflict():

0 commit comments

Comments
 (0)