Skip to content

Commit

Permalink
Test extensions of "parent" dependencies
Browse files Browse the repository at this point in the history
These are the main correctness fix from #55910, so it's important that
we have test coverage for it.
  • Loading branch information
topolarity committed Nov 24, 2024
1 parent 0bedaae commit a1dbfd0
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,40 @@ end
@test occursin("Hello x-package ext-to-ext!", String(read(cmd)))
end

# Extensions for "parent" dependencies
# (i.e. an `ExtAB` where A depends on / loads B, but B provides the extension)

mktempdir() do depot # Parallel pre-compilation
code = """
Base.disable_parallel_precompile = false
using Parent
Base.get_extension(getfield(Parent, :DepWithParentExt), :ParentExt) isa Module || error("expected extension to load")
Parent.greet()
"""
proj = joinpath(@__DIR__, "project", "Extensions", "Parent.jl")
cmd = `$(Base.julia_cmd()) --startup-file=no -e $code`
cmd = addenv(cmd,
"JULIA_LOAD_PATH" => proj,
"JULIA_DEPOT_PATH" => depot * Base.Filesystem.pathsep(),
)
@test occursin("Hello parent!", String(read(cmd)))
end
mktempdir() do depot # Serial pre-compilation
code = """
Base.disable_parallel_precompile = true
using Parent
Base.get_extension(getfield(Parent, :DepWithParentExt), :ParentExt) isa Module || error("expected extension to load")
Parent.greet()
"""
proj = joinpath(@__DIR__, "project", "Extensions", "Parent.jl")
cmd = `$(Base.julia_cmd()) --startup-file=no -e $code`
cmd = addenv(cmd,
"JULIA_LOAD_PATH" => proj,
"JULIA_DEPOT_PATH" => depot * Base.Filesystem.pathsep(),
)
@test occursin("Hello parent!", String(read(cmd)))
end

finally
try
rm(depot_path, force=true, recursive=true)
Expand Down
9 changes: 9 additions & 0 deletions test/project/Extensions/DepWithParentExt.jl/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name = "DepWithParentExt"
uuid = "8a35c396-5ffc-40d2-b7ec-e8ed2248da32"
version = "0.1.0"

[weakdeps]
Parent = "58cecb9c-f68a-426e-b92a-89d456ae7acc"

[extensions]
ParentExt = "Parent"
6 changes: 6 additions & 0 deletions test/project/Extensions/DepWithParentExt.jl/ext/ParentExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module ParentExt

using Parent
using DepWithParentExt

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module DepWithParentExt

greet() = print("Hello dep w/ ext for parent dep!")

end # module DepWithParentExt
20 changes: 20 additions & 0 deletions test/project/Extensions/Parent.jl/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.12.0-DEV"
manifest_format = "2.0"
project_hash = "b6ac643184d62cc94427c9aa665ff1fb63d66038"

[[deps.DepWithParentExt]]
path = "../DepWithParentExt.jl"
uuid = "8a35c396-5ffc-40d2-b7ec-e8ed2248da32"
version = "0.1.0"
weakdeps = ["Parent"]

[deps.DepWithParentExt.extensions]
ParentExt = "Parent"

[[deps.Parent]]
deps = ["DepWithParentExt"]
path = "."
uuid = "58cecb9c-f68a-426e-b92a-89d456ae7acc"
version = "0.1.0"
7 changes: 7 additions & 0 deletions test/project/Extensions/Parent.jl/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "Parent"
uuid = "58cecb9c-f68a-426e-b92a-89d456ae7acc"
version = "0.1.0"
authors = ["Cody Tapscott <[email protected]>"]

[deps]
DepWithParentExt = "8a35c396-5ffc-40d2-b7ec-e8ed2248da32"
7 changes: 7 additions & 0 deletions test/project/Extensions/Parent.jl/src/Parent.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Parent

using DepWithParentExt

greet() = print("Hello parent!")

end # module Parent

0 comments on commit a1dbfd0

Please sign in to comment.