mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-12 20:10:21 -06:00
Merge branch 'master' of github.com:pre-commit/pre-commit
This commit is contained in:
@@ -32,7 +32,7 @@ def install_environment():
|
||||
|
||||
with python.in_env() as python_env:
|
||||
python_env.run('pip install nodeenv')
|
||||
python_env.run('nodeenv {0}'.format(NODE_ENV))
|
||||
python_env.run('nodeenv --jobs 4 {0}'.format(NODE_ENV))
|
||||
|
||||
with in_env(python_env) as node_env:
|
||||
node_env.run('npm install -g')
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import jsonschema
|
||||
import simplejson
|
||||
import pytest
|
||||
import time
|
||||
from plumbum import local
|
||||
@@ -75,6 +76,59 @@ def func():
|
||||
yield dummy_git_repo
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def node_pre_commit_git_repo(dummy_git_repo):
|
||||
local.path(C.MANIFEST_FILE).write("""
|
||||
-
|
||||
id: foo
|
||||
name: Foo
|
||||
entry: foo
|
||||
language: node
|
||||
""")
|
||||
|
||||
add_and_commit()
|
||||
|
||||
local.path('package.json').write(simplejson.dumps({
|
||||
'name': 'foo',
|
||||
'version': '0.0.1',
|
||||
'bin': {
|
||||
'foo': './bin/main.js'
|
||||
},
|
||||
}))
|
||||
|
||||
bin_dir = local.path('bin')
|
||||
|
||||
bin_dir.mkdir()
|
||||
|
||||
with local.cwd(bin_dir):
|
||||
local.path('main.js').write(
|
||||
"""#!/usr/bin/env node
|
||||
|
||||
console.log('Hello World');
|
||||
""")
|
||||
|
||||
add_and_commit()
|
||||
|
||||
yield dummy_git_repo
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config_for_node_pre_commit_git_repo(node_pre_commit_git_repo):
|
||||
config = {
|
||||
'repo': node_pre_commit_git_repo,
|
||||
'sha': git.get_head_sha(node_pre_commit_git_repo),
|
||||
'hooks': [{
|
||||
'id': 'foo',
|
||||
'files': '*.js',
|
||||
}],
|
||||
}
|
||||
|
||||
jsonschema.validate([config], CONFIG_JSON_SCHEMA)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config_for_python_pre_commit_git_repo(python_pre_commit_git_repo):
|
||||
config = {
|
||||
|
||||
@@ -43,7 +43,7 @@ def test_install_python_repo_in_env(python_pre_commit_git_repo, config_for_pytho
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_run_a_hook_omg(config_for_python_pre_commit_git_repo):
|
||||
def test_run_a_python_hook(config_for_python_pre_commit_git_repo):
|
||||
repo = Repository(config_for_python_pre_commit_git_repo)
|
||||
repo.install()
|
||||
ret = repo.run_hook('foo', [])
|
||||
@@ -52,6 +52,15 @@ def test_run_a_hook_omg(config_for_python_pre_commit_git_repo):
|
||||
assert ret[1] == 'Hello World\n'
|
||||
|
||||
|
||||
@pytest.mark.skipif(True, reason="TODO: make this test not super slow")
|
||||
def test_run_a_node_hook(config_for_node_pre_commit_git_repo):
|
||||
repo = Repository(config_for_node_pre_commit_git_repo)
|
||||
repo.install()
|
||||
ret = repo.run_hook('foo', [])
|
||||
|
||||
assert ret[0] == 0
|
||||
assert ret[1] == 'Hello World\n'
|
||||
|
||||
@pytest.fixture
|
||||
def mock_repo_config():
|
||||
config = {
|
||||
@@ -83,3 +92,5 @@ def test_languages(config_for_python_pre_commit_git_repo):
|
||||
repo = Repository(config_for_python_pre_commit_git_repo)
|
||||
assert repo.languages == set(['python'])
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user