# Path: pre_commit/languages/r.py
# ENVIRONMENT_DIR = 'renv'
# RSCRIPT_OPTS = ('--no-save', '--no-restore', '--no-site-file', '--no-environ')
# def get_env_patch(venv: str) -> PatchesT:
# def in_env(
#         prefix: Prefix,
#         language_version: str,
# ) -> Generator[None, None, None]:
# def _get_env_dir(prefix: Prefix, version: str) -> str:
# def _prefix_if_non_local_file_entry(
#     entry: Sequence[str],
#     prefix: Prefix,
#     src: str,
# ) -> Sequence[str]:
# def _rscript_exec() -> str:
# def _entry_validate(entry: Sequence[str]) -> None:
# def _cmd_from_hook(hook: Hook) -> tuple[str, ...]:
# def install_environment(
#         prefix: Prefix,
#         version: str,
#         additional_dependencies: Sequence[str],
# ) -> None:
# def _inline_r_setup(code: str) -> str:
# def run_hook(
#         hook: Hook,
#         file_args: Sequence[str],
#         color: bool,
# ) -> tuple[int, bytes]:
# 
# Path: testing/fixtures.py
# def make_config_from_repo(repo_path, rev=None, hooks=None, check=True):
#     manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
#     config = {
#         'repo': f'file://{repo_path}',
#         'rev': rev or git.head_rev(repo_path),
#         'hooks': hooks or [{'id': hook['id']} for hook in manifest],
#     }
# 
#     if check:
#         wrapped = validate({'repos': [config]}, CONFIG_SCHEMA)
#         wrapped = apply_defaults(wrapped, CONFIG_SCHEMA)
#         config, = wrapped['repos']
#         return config
#     else:
#         return config
# 
# Path: testing/fixtures.py
# def make_repo(tempdir_factory, repo_source):
#     path = git_dir(tempdir_factory)
#     copy_tree_to_path(get_resource_path(repo_source), path)
#     cmd_output('git', 'add', '.', cwd=path)
#     git_commit(msg=make_repo.__name__, cwd=path)
#     return path
# 
# Path: tests/repository_test.py
# def _get_hook_no_install(repo_config, store, hook_id):
#     config = {'repos': [repo_config]}
#     config = cfgv.validate(config, CONFIG_SCHEMA)
#     config = cfgv.apply_defaults(config, CONFIG_SCHEMA)
#     hooks = all_hooks(config, store)
#     hook, = (hook for hook in hooks if hook.id == hook_id)
#     return hook


import os.path
import pytest
from pre_commit.languages import r
from testing.fixtures import make_config_from_repo
from testing.fixtures import make_repo
from tests.repository_test import _get_hook_no_install
from __future__ import annotations





def _test_r_parsing(
    tempdir_factory,
    store,
    hook_id,
    expected_hook_expr={},
    expected_args={},
    config={},
    expect_path_prefix=True,
):
    repo_path = 'r_hooks_repo'

# Path: pre_commit/languages/r.py
# ENVIRONMENT_DIR = 'renv'
# RSCRIPT_OPTS = ('--no-save', '--no-restore', '--no-site-file', '--no-environ')
# def get_env_patch(venv: str) -> PatchesT:
# def in_env(
#         prefix: Prefix,
#         language_version: str,
# ) -> Generator[None, None, None]:
# def _get_env_dir(prefix: Prefix, version: str) -> str:
# def _prefix_if_non_local_file_entry(
#     entry: Sequence[str],
#     prefix: Prefix,
#     src: str,
# ) -> Sequence[str]:
# def _rscript_exec() -> str:
# def _entry_validate(entry: Sequence[str]) -> None:
# def _cmd_from_hook(hook: Hook) -> tuple[str, ...]:
# def install_environment(
#         prefix: Prefix,
#         version: str,
#         additional_dependencies: Sequence[str],
# ) -> None:
# def _inline_r_setup(code: str) -> str:
# def run_hook(
#         hook: Hook,
#         file_args: Sequence[str],
#         color: bool,
# ) -> tuple[int, bytes]:
# 
# Path: testing/fixtures.py
# def make_config_from_repo(repo_path, rev=None, hooks=None, check=True):
#     manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
#     config = {
#         'repo': f'file://{repo_path}',
#         'rev': rev or git.head_rev(repo_path),
#         'hooks': hooks or [{'id': hook['id']} for hook in manifest],
#     }
# 
#     if check:
#         wrapped = validate({'repos': [config]}, CONFIG_SCHEMA)
#         wrapped = apply_defaults(wrapped, CONFIG_SCHEMA)
#         config, = wrapped['repos']
#         return config
#     else:
#         return config
# 
# Path: testing/fixtures.py
# def make_repo(tempdir_factory, repo_source):
#     path = git_dir(tempdir_factory)
#     copy_tree_to_path(get_resource_path(repo_source), path)
#     cmd_output('git', 'add', '.', cwd=path)
#     git_commit(msg=make_repo.__name__, cwd=path)
#     return path
# 
# Path: tests/repository_test.py
# def _get_hook_no_install(repo_config, store, hook_id):
#     config = {'repos': [repo_config]}
#     config = cfgv.validate(config, CONFIG_SCHEMA)
#     config = cfgv.apply_defaults(config, CONFIG_SCHEMA)
#     hooks = all_hooks(config, store)
#     hook, = (hook for hook in hooks if hook.id == hook_id)
#     return hook


# Path: tests/languages/r_test.py
import os.path
import pytest
from pre_commit.languages import r
from testing.fixtures import make_config_from_repo
from testing.fixtures import make_repo
from tests.repository_test import _get_hook_no_install

from __future__ import annotations





def _test_r_parsing(
    tempdir_factory,
    store,
    hook_id,
    expected_hook_expr={},
    expected_args={},
    config={},
    expect_path_prefix=True,
):
    repo_path = 'r_hooks_repo'

    path = make_repo(tempdir_factory, repo_path)