mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 16:44:42 +04:00
Add tests for Rust
This commit is contained in:
parent
2a37fcd3fe
commit
b4edf2ce50
6 changed files with 74 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ from pre_commit.languages import node
|
|||
from pre_commit.languages import pcre
|
||||
from pre_commit.languages import python
|
||||
from pre_commit.languages import ruby
|
||||
from pre_commit.languages import rust
|
||||
from pre_commit.repository import Repository
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.fixtures import config_with_local_hooks
|
||||
|
|
@ -282,6 +283,51 @@ def test_golang_hook(tempdir_factory, store):
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_rust_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'rust_hooks_repo',
|
||||
'rust-hook', [], b'hello world\n',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
@pytest.mark.parametrize('dep', ('cli:shellharden:3.1.0', 'cli:shellharden'))
|
||||
def test_additional_rust_cli_dependencies_installed(
|
||||
tempdir_factory, store, dep,
|
||||
):
|
||||
path = make_repo(tempdir_factory, 'rust_hooks_repo')
|
||||
config = make_config_from_repo(path)
|
||||
# A small rust package with no dependencies.
|
||||
config['hooks'][0]['additional_dependencies'] = [dep]
|
||||
repo = Repository.create(config, store)
|
||||
repo.require_installed()
|
||||
(prefix, _, _, _), = repo._venvs()
|
||||
binaries = os.listdir(prefix.path(
|
||||
helpers.environment_dir(rust.ENVIRONMENT_DIR, 'default'), 'bin',
|
||||
))
|
||||
assert 'shellharden' in binaries
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_additional_rust_lib_dependencies_installed(
|
||||
tempdir_factory, store,
|
||||
):
|
||||
path = make_repo(tempdir_factory, 'rust_hooks_repo')
|
||||
config = make_config_from_repo(path)
|
||||
# A small rust package with no dependencies.
|
||||
deps = ['shellharden:3.1.0']
|
||||
config['hooks'][0]['additional_dependencies'] = deps
|
||||
repo = Repository.create(config, store)
|
||||
repo.require_installed()
|
||||
(prefix, _, _, _), = repo._venvs()
|
||||
binaries = os.listdir(prefix.path(
|
||||
helpers.environment_dir(rust.ENVIRONMENT_DIR, 'default'), 'bin',
|
||||
))
|
||||
assert 'rust-hello-world' in binaries
|
||||
assert 'shellharden' not in binaries
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_missing_executable(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue