mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add Runner interface.
This commit is contained in:
parent
ae1d1681b2
commit
88686d298f
25 changed files with 282 additions and 148 deletions
0
testing/__init__.py
Normal file
0
testing/__init__.py
Normal file
2
testing/resources/array_yaml_file.yaml
Normal file
2
testing/resources/array_yaml_file.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
- foo
|
||||
- bar
|
||||
22
testing/resources/consumer_repo/.pre-commit-config.yaml
Normal file
22
testing/resources/consumer_repo/.pre-commit-config.yaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
- repo: git@github.com:pre-commit/pre-commit-hooks
|
||||
sha: 76739902911688e8d7b13241409f9facc0e534e4
|
||||
hooks:
|
||||
- id: pyflakes
|
||||
files: '\.py$'
|
||||
- id: debug-statements
|
||||
files: '\.py$'
|
||||
- id: trailing-whitespace
|
||||
files: '\.(py|sh|yaml)$'
|
||||
- id: name-tests-test
|
||||
files: 'tests/.+\.py$'
|
||||
- id: end-of-file-fixer
|
||||
files: '\.(py|sh|yaml)$'
|
||||
|
||||
- repo: git@github.com:pre-commit/pre-commit
|
||||
sha: 47b7ca44ed1fcaa83464ed00cef72049ae22c33d
|
||||
hooks:
|
||||
- id: validate_manifest
|
||||
files: '^manifest.yaml$'
|
||||
- id: validate_config
|
||||
files: \.pre-commit-config.yaml
|
||||
3
testing/resources/node_hooks_repo/bin/main.js
Normal file
3
testing/resources/node_hooks_repo/bin/main.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
console.log('Hello World');
|
||||
4
testing/resources/node_hooks_repo/manifest.yaml
Normal file
4
testing/resources/node_hooks_repo/manifest.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
- id: foo
|
||||
name: Foo
|
||||
entry: foo
|
||||
language: node
|
||||
5
testing/resources/node_hooks_repo/package.json
Normal file
5
testing/resources/node_hooks_repo/package.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "foo",
|
||||
"version": "0.0.1",
|
||||
"bin": {"foo": "./bin/main.js"}
|
||||
}
|
||||
1
testing/resources/non_parseable_yaml_file.yaml
Normal file
1
testing/resources/non_parseable_yaml_file.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
foo: "
|
||||
0
testing/resources/python_hooks_repo/foo/__init__.py
Normal file
0
testing/resources/python_hooks_repo/foo/__init__.py
Normal file
6
testing/resources/python_hooks_repo/foo/main.py
Normal file
6
testing/resources/python_hooks_repo/foo/main.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import sys
|
||||
|
||||
def func():
|
||||
print repr(sys.argv[1:])
|
||||
print 'Hello World'
|
||||
return 0
|
||||
4
testing/resources/python_hooks_repo/manifest.yaml
Normal file
4
testing/resources/python_hooks_repo/manifest.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
- id: foo
|
||||
name: Foo
|
||||
entry: foo
|
||||
language: python
|
||||
11
testing/resources/python_hooks_repo/setup.py
Normal file
11
testing/resources/python_hooks_repo/setup.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from setuptools import find_packages
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='Foo',
|
||||
version='0.0.0',
|
||||
packages=find_packages('.'),
|
||||
entry_points={
|
||||
'console_scripts': ['foo = foo.main:func'],
|
||||
},
|
||||
)
|
||||
7
testing/resources/valid_yaml_but_invalid_config.yaml
Normal file
7
testing/resources/valid_yaml_but_invalid_config.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
- repo: git@github.com:pre-commit/pre-commit-hooks
|
||||
hooks:
|
||||
- id: pyflakes
|
||||
- id: jslint
|
||||
- id: trim_trailing_whitespace
|
||||
files: '*.py'
|
||||
1
testing/resources/valid_yaml_but_invalid_manifest.yaml
Normal file
1
testing/resources/valid_yaml_but_invalid_manifest.yaml
Normal file
|
|
@ -0,0 +1 @@
|
|||
foo: bar
|
||||
29
testing/util.py
Normal file
29
testing/util.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
import os
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
|
||||
TESTING_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
def get_resource_path(path):
|
||||
return os.path.join(TESTING_DIR, 'resources', path)
|
||||
|
||||
|
||||
def copy_tree_to_path(src_dir, dest_dir):
|
||||
"""Copies all of the things inside src_dir to an already existing dest_dir.
|
||||
|
||||
This looks eerily similar to shutil.copytree, but copytree has no option
|
||||
for not creating dest_dir.
|
||||
"""
|
||||
names = os.listdir(src_dir)
|
||||
|
||||
for name in names:
|
||||
srcname = os.path.join(src_dir, name)
|
||||
destname = os.path.join(dest_dir, name)
|
||||
|
||||
if os.path.isdir(srcname):
|
||||
shutil.copytree(srcname, destname)
|
||||
else:
|
||||
shutil.copy(srcname, destname)
|
||||
Loading…
Add table
Add a link
Reference in a new issue