mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
coursier: additional_dependencies support
This commit is contained in:
parent
59ed51a309
commit
70bfd76ced
10 changed files with 132 additions and 66 deletions
45
tests/languages/coursier_test.py
Normal file
45
tests/languages/coursier_test.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from pre_commit.errors import FatalError
|
||||
from pre_commit.languages import coursier
|
||||
from testing.language_helpers import run_language
|
||||
|
||||
|
||||
def test_coursier_hook(tmp_path):
|
||||
echo_java_json = '''\
|
||||
{
|
||||
"repositories": ["central"],
|
||||
"dependencies": ["io.get-coursier:echo:latest.stable"]
|
||||
}
|
||||
'''
|
||||
|
||||
channel_dir = tmp_path.joinpath('.pre-commit-channel')
|
||||
channel_dir.mkdir()
|
||||
channel_dir.joinpath('echo-java.json').write_text(echo_java_json)
|
||||
|
||||
ret = run_language(
|
||||
tmp_path,
|
||||
coursier,
|
||||
'echo-java',
|
||||
args=('Hello', 'World', 'from', 'coursier'),
|
||||
)
|
||||
assert ret == (0, b'Hello World from coursier\n')
|
||||
|
||||
|
||||
def test_coursier_hook_additional_dependencies(tmp_path):
|
||||
ret = run_language(
|
||||
tmp_path,
|
||||
coursier,
|
||||
'scalafmt --version',
|
||||
deps=('scalafmt:3.6.1',),
|
||||
)
|
||||
assert ret == (0, b'scalafmt 3.6.1\n')
|
||||
|
||||
|
||||
def test_error_if_no_deps_or_channel(tmp_path):
|
||||
with pytest.raises(FatalError) as excinfo:
|
||||
run_language(tmp_path, coursier, 'dne')
|
||||
msg, = excinfo.value.args
|
||||
assert msg == 'expected .pre-commit-channel dir or additional_dependencies'
|
||||
|
|
@ -32,7 +32,6 @@ from testing.fixtures import make_repo
|
|||
from testing.fixtures import modify_manifest
|
||||
from testing.util import cwd
|
||||
from testing.util import get_resource_path
|
||||
from testing.util import skipif_cant_run_coursier
|
||||
from testing.util import skipif_cant_run_docker
|
||||
from testing.util import skipif_cant_run_lua
|
||||
from testing.util import skipif_cant_run_swift
|
||||
|
|
@ -199,15 +198,6 @@ def test_language_versioned_python_hook(tempdir_factory, store):
|
|||
)
|
||||
|
||||
|
||||
@skipif_cant_run_coursier # pragma: win32 no cover
|
||||
def test_run_a_coursier_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'coursier_hooks_repo',
|
||||
'echo-java',
|
||||
['Hello World from coursier'], b'Hello World from coursier\n',
|
||||
)
|
||||
|
||||
|
||||
@skipif_cant_run_docker # pragma: win32 no cover
|
||||
def test_run_a_docker_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue