Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow extensions to be loaded from non top level env #48352

Merged
merged 1 commit into from
Jan 19, 2023
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
1 change: 0 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,6 @@ function insert_extension_triggers(pkg::PkgId)
pkg.uuid === nothing && return
for env in load_path()
insert_extension_triggers(env, pkg)
break # For now, only insert triggers for packages in the first load_path.
end
end

Expand Down
43 changes: 28 additions & 15 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1000,24 +1000,37 @@ end
try
tmp = mktempdir()
push!(empty!(DEPOT_PATH), joinpath(tmp, "depot"))

proj = joinpath(@__DIR__, "project", "Extensions", "HasDepWithExtensions.jl")
for compile in (`--compiled-modules=no`, ``, ``) # Once when requiring precomilation, once where it is already precompiled
cmd = `$(Base.julia_cmd()) $compile --project=$proj --startup-file=no -e '
begin
using HasExtensions
# Base.get_extension(HasExtensions, :Extension) === nothing || error("unexpectedly got an extension")
HasExtensions.ext_loaded && error("ext_loaded set")
using HasDepWithExtensions
# Base.get_extension(HasExtensions, :Extension).extvar == 1 || error("extvar in Extension not set")
HasExtensions.ext_loaded || error("ext_loaded not set")
HasExtensions.ext_folder_loaded && error("ext_folder_loaded set")
HasDepWithExtensions.do_something() || error("do_something errored")
using ExtDep2
HasExtensions.ext_folder_loaded || error("ext_folder_loaded not set")

function gen_extension_cmd(compile)
```$(Base.julia_cmd()) $compile --startup-file=no -e '
begin
using HasExtensions
# Base.get_extension(HasExtensions, :Extension) === nothing || error("unexpectedly got an extension")
HasExtensions.ext_loaded && error("ext_loaded set")
using HasDepWithExtensions
# Base.get_extension(HasExtensions, :Extension).extvar == 1 || error("extvar in Extension not set")
HasExtensions.ext_loaded || error("ext_loaded not set")
HasExtensions.ext_folder_loaded && error("ext_folder_loaded set")
HasDepWithExtensions.do_something() || error("do_something errored")
using ExtDep2
HasExtensions.ext_folder_loaded || error("ext_folder_loaded not set")
end
'`
'
```
end

for compile in (`--compiled-modules=no`, ``, ``) # Once when requiring precomilation, once where it is already precompiled
cmd = gen_extension_cmd(compile)
withenv("JULIA_LOAD_PATH" => proj) do
@test success(cmd)
end
end

# 48351
sep = Sys.iswindows() ? ';' : ':'
withenv("JULIA_LOAD_PATH" => join([mktempdir(), proj], sep)) do
cmd = gen_extension_cmd(``)
@test success(cmd)
end
finally
Expand Down