Merging upstream version 2.6.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
83b41af7b3
commit
f6afa19b5d
9 changed files with 111 additions and 41 deletions
|
@ -1,15 +1,39 @@
|
|||
import os.path
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import parse_shebang
|
||||
from pre_commit.languages import ruby
|
||||
from pre_commit.prefix import Prefix
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.util import xfailif_windows_no_ruby
|
||||
from testing.util import xfailif_windows
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby
|
||||
ACTUAL_GET_DEFAULT_VERSION = ruby.get_default_version.__wrapped__
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def find_exe_mck():
|
||||
with mock.patch.object(parse_shebang, 'find_executable') as mck:
|
||||
yield mck
|
||||
|
||||
|
||||
def test_uses_default_version_when_not_available(find_exe_mck):
|
||||
find_exe_mck.return_value = None
|
||||
assert ACTUAL_GET_DEFAULT_VERSION() == C.DEFAULT
|
||||
|
||||
|
||||
def test_uses_system_if_both_gem_and_ruby_are_available(find_exe_mck):
|
||||
find_exe_mck.return_value = '/path/to/exe'
|
||||
assert ACTUAL_GET_DEFAULT_VERSION() == 'system'
|
||||
|
||||
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_install_rbenv(tempdir_factory):
|
||||
prefix = Prefix(tempdir_factory.get())
|
||||
ruby._install_rbenv(prefix)
|
||||
ruby._install_rbenv(prefix, C.DEFAULT)
|
||||
# Should have created rbenv directory
|
||||
assert os.path.exists(prefix.path('rbenv-default'))
|
||||
|
||||
|
@ -18,7 +42,7 @@ def test_install_rbenv(tempdir_factory):
|
|||
cmd_output('rbenv', '--help')
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_install_rbenv_with_version(tempdir_factory):
|
||||
prefix = Prefix(tempdir_factory.get())
|
||||
ruby._install_rbenv(prefix, version='1.9.3p547')
|
||||
|
|
|
@ -34,7 +34,6 @@ from testing.util import get_resource_path
|
|||
from testing.util import skipif_cant_run_docker
|
||||
from testing.util import skipif_cant_run_swift
|
||||
from testing.util import xfailif_windows
|
||||
from testing.util import xfailif_windows_no_ruby
|
||||
|
||||
|
||||
def _norm_out(b):
|
||||
|
@ -235,6 +234,7 @@ def test_run_a_docker_image_hook(tempdir_factory, store, hook_id):
|
|||
)
|
||||
|
||||
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_run_a_node_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'node_hooks_repo',
|
||||
|
@ -260,7 +260,14 @@ def test_run_versioned_node_hook(tempdir_factory, store):
|
|||
)
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_node_hook_with_npm_userconfig_set(tempdir_factory, store, tmpdir):
|
||||
cfg = tmpdir.join('cfg')
|
||||
cfg.write('cache=/dne\n')
|
||||
with mock.patch.dict(os.environ, NPM_CONFIG_USERCONFIG=str(cfg)):
|
||||
test_run_a_node_hook(tempdir_factory, store)
|
||||
|
||||
|
||||
def test_run_a_ruby_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'ruby_hooks_repo',
|
||||
|
@ -268,7 +275,7 @@ def test_run_a_ruby_hook(tempdir_factory, store):
|
|||
)
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_run_versioned_ruby_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'ruby_versioned_hooks_repo',
|
||||
|
@ -278,7 +285,7 @@ def test_run_versioned_ruby_hook(tempdir_factory, store):
|
|||
)
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby
|
||||
@xfailif_windows # pragma: win32 no cover
|
||||
def test_run_ruby_hook_with_disable_shared_gems(
|
||||
tempdir_factory,
|
||||
store,
|
||||
|
@ -524,7 +531,6 @@ def test_additional_dependencies_roll_forward(tempdir_factory, store):
|
|||
assert 'mccabe' not in cmd_output('pip', 'freeze', '-l')[1]
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby # pragma: win32 no cover
|
||||
def test_additional_ruby_dependencies_installed(tempdir_factory, store):
|
||||
path = make_repo(tempdir_factory, 'ruby_hooks_repo')
|
||||
config = make_config_from_repo(path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue