Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pre_commit/languages/julia.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run_hook(

cmd = lang_base.hook_cmd(entry, args)
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(
cmd,
file_args,
Expand Down Expand Up @@ -127,6 +127,7 @@ def install_environment(
end
"""
cmd_output_b(
'julia', '-e', julia_code, '--', envdir, *additional_dependencies,
'julia', '--startup-file=no', '-e', julia_code, '--', envdir,
*additional_dependencies,
cwd=prefix.prefix_dir,
)
14 changes: 14 additions & 0 deletions tests/languages/julia_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

import os
from unittest import mock

from pre_commit.languages import julia
from testing.language_helpers import run_language
from testing.util import cwd
Expand Down Expand Up @@ -28,6 +31,17 @@ def test_julia_hook(tmp_path):
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):
code = """
using Example
Expand Down
Loading