summaryrefslogtreecommitdiffstats
path: root/tests/meta_hooks
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-06 04:23:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-06 04:23:44 +0000
commit8b9f67e46f462980dd0877e752954a07bfecdb32 (patch)
tree7455f28cae7a78fdec431903475978bbff39f984 /tests/meta_hooks
parentAdding upstream version 2.14.0. (diff)
downloadpre-commit-8b9f67e46f462980dd0877e752954a07bfecdb32.tar.xz
pre-commit-8b9f67e46f462980dd0877e752954a07bfecdb32.zip
Adding upstream version 2.15.0.upstream/2.15.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/meta_hooks')
-rw-r--r--tests/meta_hooks/check_useless_excludes_test.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/meta_hooks/check_useless_excludes_test.py b/tests/meta_hooks/check_useless_excludes_test.py
index d261e81..703bd25 100644
--- a/tests/meta_hooks/check_useless_excludes_test.py
+++ b/tests/meta_hooks/check_useless_excludes_test.py
@@ -1,5 +1,10 @@
+from pre_commit import git
from pre_commit.meta_hooks import check_useless_excludes
+from pre_commit.util import cmd_output
from testing.fixtures import add_config_to_repo
+from testing.fixtures import make_config_from_repo
+from testing.fixtures import make_repo
+from testing.util import xfailif_windows
def test_useless_exclude_global(capsys, in_git_dir):
@@ -113,3 +118,20 @@ def test_valid_exclude(capsys, in_git_dir):
out, _ = capsys.readouterr()
assert out == ''
+
+
+@xfailif_windows # pragma: win32 no cover
+def test_useless_excludes_broken_symlink(capsys, in_git_dir, tempdir_factory):
+ path = make_repo(tempdir_factory, 'script_hooks_repo')
+ config = make_config_from_repo(path)
+ config['hooks'][0]['exclude'] = 'broken-symlink'
+ add_config_to_repo(in_git_dir.strpath, config)
+
+ in_git_dir.join('broken-symlink').mksymlinkto('DNE')
+ cmd_output('git', 'add', 'broken-symlink')
+ git.commit()
+
+ assert check_useless_excludes.main(('.pre-commit-config.yaml',)) == 0
+
+ out, _ = capsys.readouterr()
+ assert out == ''