mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fixups to make appveyor happy
This commit is contained in:
parent
1e5c3324e3
commit
b6937f33e2
8 changed files with 41 additions and 43 deletions
|
|
@ -14,6 +14,8 @@ omit =
|
|||
exclude_lines =
|
||||
# Have to re-enable the standard pragma
|
||||
\#\s*pragma: no cover
|
||||
# We optionally substitute this
|
||||
${COVERAGE_IGNORE_WINDOWS}
|
||||
|
||||
# Don't complain if tests don't hit defensive assertion code:
|
||||
^\s*raise AssertionError\b
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
environment:
|
||||
global:
|
||||
COVERAGE_IGNORE_WINDOWS: '# pragma: windows no cover'
|
||||
TOX_TESTENV_PASSENV: COVERAGE_IGNORE_WINDOWS
|
||||
matrix:
|
||||
- TOXENV: py27
|
||||
- TOXENV: py35
|
||||
|
|
|
|||
|
|
@ -16,30 +16,30 @@ ENVIRONMENT_DIR = 'docker'
|
|||
PRE_COMMIT_LABEL = 'PRE_COMMIT'
|
||||
|
||||
|
||||
def md5(s):
|
||||
def md5(s): # pragma: windows no cover
|
||||
return hashlib.md5(five.to_bytes(s)).hexdigest()
|
||||
|
||||
|
||||
def docker_tag(repo_cmd_runner):
|
||||
def docker_tag(repo_cmd_runner): # pragma: windows no cover
|
||||
return 'pre-commit-{}'.format(
|
||||
md5(os.path.basename(repo_cmd_runner.path()))
|
||||
).lower()
|
||||
|
||||
|
||||
def docker_is_running():
|
||||
def docker_is_running(): # pragma: windows no cover
|
||||
try:
|
||||
return cmd_output('docker', 'ps')[0] == 0
|
||||
except CalledProcessError:
|
||||
return False
|
||||
|
||||
|
||||
def assert_docker_available():
|
||||
def assert_docker_available(): # pragma: windows no cover
|
||||
assert docker_is_running(), (
|
||||
'Docker is either not running or not configured in this environment'
|
||||
)
|
||||
|
||||
|
||||
def build_docker_image(repo_cmd_runner, **kwargs):
|
||||
def build_docker_image(repo_cmd_runner, **kwargs): # pragma: windows no cover
|
||||
pull = kwargs.pop('pull')
|
||||
assert not kwargs, kwargs
|
||||
cmd = (
|
||||
|
|
@ -56,7 +56,7 @@ def install_environment(
|
|||
repo_cmd_runner,
|
||||
version='default',
|
||||
additional_dependencies=(),
|
||||
):
|
||||
): # pragma: windows no cover
|
||||
assert repo_cmd_runner.exists('Dockerfile'), (
|
||||
'No Dockerfile was found in the hook repository'
|
||||
)
|
||||
|
|
@ -65,9 +65,9 @@ def install_environment(
|
|||
)
|
||||
assert_docker_available()
|
||||
|
||||
directory = repo_cmd_runner.path(helpers.environment_dir(
|
||||
ENVIRONMENT_DIR, 'default',
|
||||
))
|
||||
directory = repo_cmd_runner.path(
|
||||
helpers.environment_dir(ENVIRONMENT_DIR, 'default'),
|
||||
)
|
||||
|
||||
# Docker doesn't really have relevant disk environment, but pre-commit
|
||||
# still needs to cleanup it's state files on failure
|
||||
|
|
@ -76,7 +76,7 @@ def install_environment(
|
|||
os.mkdir(directory)
|
||||
|
||||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
def run_hook(repo_cmd_runner, hook, file_args): # pragma: windows no cover
|
||||
assert_docker_available()
|
||||
# Rebuild the docker image in case it has gone missing, as many people do
|
||||
# automated cleanup of docker images.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from pre_commit.xargs import xargs
|
|||
ENVIRONMENT_DIR = 'node_env'
|
||||
|
||||
|
||||
def get_env_patch(venv):
|
||||
def get_env_patch(venv): # pragma: windows no cover
|
||||
return (
|
||||
('NODE_VIRTUAL_ENV', venv),
|
||||
('NPM_CONFIG_PREFIX', venv),
|
||||
|
|
@ -25,9 +25,8 @@ def get_env_patch(venv):
|
|||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def in_env(repo_cmd_runner, language_version):
|
||||
envdir = os.path.join(
|
||||
repo_cmd_runner.prefix_dir,
|
||||
def in_env(repo_cmd_runner, language_version): # pragma: windows no cover
|
||||
envdir = repo_cmd_runner.path(
|
||||
helpers.environment_dir(ENVIRONMENT_DIR, language_version),
|
||||
)
|
||||
with envcontext(get_env_patch(envdir)):
|
||||
|
|
@ -38,7 +37,7 @@ def install_environment(
|
|||
repo_cmd_runner,
|
||||
version='default',
|
||||
additional_dependencies=(),
|
||||
):
|
||||
): # pragma: windows no cover
|
||||
additional_dependencies = tuple(additional_dependencies)
|
||||
assert repo_cmd_runner.exists('package.json')
|
||||
directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
|
||||
|
|
@ -62,6 +61,6 @@ def install_environment(
|
|||
)
|
||||
|
||||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
def run_hook(repo_cmd_runner, hook, file_args): # pragma: windows no cover
|
||||
with in_env(repo_cmd_runner, hook['language_version']):
|
||||
return xargs(helpers.to_cmd(hook), file_args)
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ def get_env_patch(venv):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def in_env(repo_cmd_runner, language_version):
|
||||
envdir = os.path.join(
|
||||
repo_cmd_runner.prefix_dir,
|
||||
envdir = repo_cmd_runner.path(
|
||||
helpers.environment_dir(ENVIRONMENT_DIR, language_version),
|
||||
)
|
||||
with envcontext(get_env_patch(envdir)):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from pre_commit.xargs import xargs
|
|||
ENVIRONMENT_DIR = 'rbenv'
|
||||
|
||||
|
||||
def get_env_patch(venv, language_version):
|
||||
def get_env_patch(venv, language_version): # pragma: windows no cover
|
||||
patches = (
|
||||
('GEM_HOME', os.path.join(venv, 'gems')),
|
||||
('RBENV_ROOT', venv),
|
||||
|
|
@ -34,16 +34,17 @@ def get_env_patch(venv, language_version):
|
|||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def in_env(repo_cmd_runner, language_version):
|
||||
envdir = os.path.join(
|
||||
repo_cmd_runner.prefix_dir,
|
||||
def in_env(repo_cmd_runner, language_version): # pragma: windows no cover
|
||||
envdir = repo_cmd_runner.path(
|
||||
helpers.environment_dir(ENVIRONMENT_DIR, language_version),
|
||||
)
|
||||
with envcontext(get_env_patch(envdir, language_version)):
|
||||
yield
|
||||
|
||||
|
||||
def _install_rbenv(repo_cmd_runner, version='default'):
|
||||
def _install_rbenv(
|
||||
repo_cmd_runner, version='default',
|
||||
): # pragma: windows no cover
|
||||
directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
|
||||
|
||||
with tarfile.open(resource_filename('rbenv.tar.gz')) as tf:
|
||||
|
|
@ -86,7 +87,7 @@ def _install_rbenv(repo_cmd_runner, version='default'):
|
|||
activate_file.write('export RBENV_VERSION="{}"\n'.format(version))
|
||||
|
||||
|
||||
def _install_ruby(runner, version):
|
||||
def _install_ruby(runner, version): # pragma: windows no cover
|
||||
try:
|
||||
helpers.run_setup_cmd(runner, ('rbenv', 'download', version))
|
||||
except CalledProcessError: # pragma: no cover (usually find with download)
|
||||
|
|
@ -98,7 +99,7 @@ def install_environment(
|
|||
repo_cmd_runner,
|
||||
version='default',
|
||||
additional_dependencies=(),
|
||||
):
|
||||
): # pragma: windows no cover
|
||||
additional_dependencies = tuple(additional_dependencies)
|
||||
directory = helpers.environment_dir(ENVIRONMENT_DIR, version)
|
||||
with clean_path_on_failure(repo_cmd_runner.path(directory)):
|
||||
|
|
@ -126,6 +127,6 @@ def install_environment(
|
|||
)
|
||||
|
||||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
def run_hook(repo_cmd_runner, hook, file_args): # pragma: windows no cover
|
||||
with in_env(repo_cmd_runner, hook['language_version']):
|
||||
return xargs(helpers.to_cmd(hook), file_args)
|
||||
|
|
|
|||
|
|
@ -14,20 +14,14 @@ BUILD_DIR = '.build'
|
|||
BUILD_CONFIG = 'release'
|
||||
|
||||
|
||||
def get_env_patch(venv):
|
||||
def get_env_patch(venv): # pragma: windows no cover
|
||||
bin_path = os.path.join(venv, BUILD_DIR, BUILD_CONFIG)
|
||||
patches = (
|
||||
('PATH', (
|
||||
bin_path, os.pathsep, Var('PATH'),
|
||||
)),
|
||||
)
|
||||
return patches
|
||||
return (('PATH', (bin_path, os.pathsep, Var('PATH'))),)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def in_env(repo_cmd_runner):
|
||||
envdir = os.path.join(
|
||||
repo_cmd_runner.prefix_dir,
|
||||
def in_env(repo_cmd_runner): # pragma: windows no cover
|
||||
envdir = repo_cmd_runner.path(
|
||||
helpers.environment_dir(ENVIRONMENT_DIR, 'default'),
|
||||
)
|
||||
with envcontext(get_env_patch(envdir)):
|
||||
|
|
@ -38,13 +32,13 @@ def install_environment(
|
|||
repo_cmd_runner,
|
||||
version='default',
|
||||
additional_dependencies=(),
|
||||
):
|
||||
): # pragma: windows no cover
|
||||
assert version == 'default', (
|
||||
'Pre-commit does not support language_version for docker '
|
||||
)
|
||||
directory = repo_cmd_runner.path(helpers.environment_dir(
|
||||
ENVIRONMENT_DIR, 'default',
|
||||
))
|
||||
directory = repo_cmd_runner.path(
|
||||
helpers.environment_dir(ENVIRONMENT_DIR, 'default'),
|
||||
)
|
||||
|
||||
# Build the swift package
|
||||
with clean_path_on_failure(directory):
|
||||
|
|
@ -57,6 +51,6 @@ def install_environment(
|
|||
))
|
||||
|
||||
|
||||
def run_hook(repo_cmd_runner, hook, file_args):
|
||||
def run_hook(repo_cmd_runner, hook, file_args): # pragma: windows no cover
|
||||
with in_env(repo_cmd_runner):
|
||||
return xargs(helpers.to_cmd(hook), file_args)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import distutils
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
import jsonschema
|
||||
import pytest
|
||||
|
||||
from pre_commit import parse_shebang
|
||||
from pre_commit.languages.docker import docker_is_running
|
||||
from pre_commit.util import cmd_output
|
||||
from pre_commit.util import cwd
|
||||
|
|
@ -70,7 +70,7 @@ skipif_slowtests_false = pytest.mark.skipif(
|
|||
)
|
||||
|
||||
skipif_cant_run_swift = pytest.mark.skipif(
|
||||
distutils.spawn.find_executable('swift') is None,
|
||||
parse_shebang.find_executable('swift') is None,
|
||||
reason='swift isn\'t installed or can\'t be found'
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue