mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Julia language: skip startup.jl file
This commit is contained in:
parent
c6817210b1
commit
6f1f433a9c
2 changed files with 17 additions and 2 deletions
|
|
@ -37,7 +37,7 @@ def run_hook(
|
||||||
|
|
||||||
cmd = lang_base.hook_cmd(entry, args)
|
cmd = lang_base.hook_cmd(entry, args)
|
||||||
script = cmd[0] if is_local else prefix.path(cmd[0])
|
script = cmd[0] if is_local else prefix.path(cmd[0])
|
||||||
cmd = ('julia', script, *cmd[1:])
|
cmd = ('julia', '--startup-file=no', script, *cmd[1:])
|
||||||
return lang_base.run_xargs(
|
return lang_base.run_xargs(
|
||||||
cmd,
|
cmd,
|
||||||
file_args,
|
file_args,
|
||||||
|
|
@ -127,6 +127,7 @@ def install_environment(
|
||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
cmd_output_b(
|
cmd_output_b(
|
||||||
'julia', '-e', julia_code, '--', envdir, *additional_dependencies,
|
'julia', '--startup-file=no', '-e', julia_code, '--', envdir,
|
||||||
|
*additional_dependencies,
|
||||||
cwd=prefix.prefix_dir,
|
cwd=prefix.prefix_dir,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
from pre_commit.languages import julia
|
from pre_commit.languages import julia
|
||||||
from testing.language_helpers import run_language
|
from testing.language_helpers import run_language
|
||||||
from testing.util import cwd
|
from testing.util import cwd
|
||||||
|
|
@ -28,6 +31,17 @@ def test_julia_hook(tmp_path):
|
||||||
assert run_language(tmp_path, julia, 'src/main.jl') == expected
|
assert run_language(tmp_path, julia, 'src/main.jl') == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_julia_hook_with_startup(tmp_path):
|
||||||
|
depot_path = tmp_path.joinpath('depot')
|
||||||
|
depot_path.joinpath('config').mkdir(parents=True)
|
||||||
|
startup = depot_path.joinpath('config', 'startup.jl')
|
||||||
|
startup.write_text('error("Startup file used!")\n')
|
||||||
|
|
||||||
|
depo_path_var = f'{depot_path}{os.pathsep}'
|
||||||
|
with mock.patch.dict(os.environ, {'JULIA_DEPOT_PATH': depo_path_var}):
|
||||||
|
test_julia_hook(tmp_path)
|
||||||
|
|
||||||
|
|
||||||
def test_julia_hook_manifest(tmp_path):
|
def test_julia_hook_manifest(tmp_path):
|
||||||
code = """
|
code = """
|
||||||
using Example
|
using Example
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue