pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pre-commit/pre-commit/pull/3497/files

ttps://github.githubassets.com/assets/primer-primitives-10bf9dd67e3d70bd.css" /> Julia: copy src files by ericphanson · Pull Request #3497 · pre-commit/pre-commit · GitHub
Skip to content
Open
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
8 changes: 8 additions & 0 deletions pre_commit/languages/julia.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def install_environment(
shutil.copy(manifest_file, envdir)
break

# copy `src` files if they exist
src_dir = prefix.path('src')
if os.path.isdir(src_dir):
shutil.copytree(
src_dir, os.path.join(envdir, 'src'),
dirs_exist_ok=True,
)

# Julia code to instantiate the hook environment
julia_code = """
@assert length(ARGS) > 0
Expand Down
38 changes: 38 additions & 0 deletions tests/languages/julia_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,41 @@ def test_julia_repo_local(tmp_path):
env_dir, julia, 'local.jl --local-arg1 --local-arg2',
deps=deps, is_local=True,
) == expected


def _make_src_hook(tmp_path, pkg_code, script_code):
# here we setup a hook with a src dir and a script dir
src_dir = tmp_path.joinpath('src')
src_dir.mkdir()
src_dir.joinpath('ExamplePkg.jl').write_text(pkg_code)

script_dir = tmp_path.joinpath('scripts')
script_dir.mkdir()
script_dir.joinpath('main.jl').write_text(script_code)

tmp_path.joinpath('Project.toml').write_text(
'name = "ExamplePkg"\n'
'uuid = "df230c44-b485-4b6a-bafb-763c50abe554"\n'
'[deps]\n'
'Example = "7876af07-990d-54b4-ab0e-23690620f79a"\n',
)


def test_julia_hook_src(tmp_path):
pkg_code = """
module ExamplePkg
using Example
export main
function main()
println("Hello, world!")
end
end
"""

script_code = """
using ExamplePkg
main()
"""
_make_src_hook(tmp_path, pkg_code, script_code)
expected = (0, b'Hello, world!\n')
assert run_language(tmp_path, julia, 'scripts/main.jl') == expected
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy