Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
topolarity committed Oct 30, 2024
1 parent 28202bc commit 85218bc
Show file tree
Hide file tree
Showing 19 changed files with 232 additions and 5 deletions.
68 changes: 68 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,74 @@ end
cmd = addenv(cmd, "JULIA_LOAD_PATH" => proj)
@test occursin("Hello Cycles!", String(read(cmd)))

# Extension-to-extension dependencies

mktempdir() do depot # Parallel pre-compilation
code = """
Base.disable_parallel_precompile = false
using ExtToExtDependency
Base.get_extension(ExtToExtDependency, :ExtA) isa Module || error("expected extension to load")
Base.get_extension(ExtToExtDependency, :ExtAB) isa Module || error("expected extension to load")
ExtToExtDependency.greet()
"""
proj = joinpath(@__DIR__, "project", "Extensions", "ExtToExtDependency")
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 ext-to-ext!", String(read(cmd)))
end
mktempdir() do depot # Serial pre-compilation
code = """
Base.disable_parallel_precompile = true
using ExtToExtDependency
Base.get_extension(ExtToExtDependency, :ExtA) isa Module || error("expected extension to load")
Base.get_extension(ExtToExtDependency, :ExtAB) isa Module || error("expected extension to load")
ExtToExtDependency.greet()
"""
proj = joinpath(@__DIR__, "project", "Extensions", "ExtToExtDependency")
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 ext-to-ext!", String(read(cmd)))
end

mktempdir() do depot # Parallel pre-compilation
code = """
Base.disable_parallel_precompile = false
using CrossPackageExtToExtDependency
Base.get_extension(CrossPackageExtToExtDependency.CyclicExtensions, :ExtA) isa Module || error("expected extension to load")
Base.get_extension(CrossPackageExtToExtDependency, :ExtAB) isa Module || error("expected extension to load")
CrossPackageExtToExtDependency.greet()
"""
proj = joinpath(@__DIR__, "project", "Extensions", "CrossPackageExtToExtDependency")
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 x-package ext-to-ext!", String(read(cmd)))
end
mktempdir() do depot # Serial pre-compilation
code = """
Base.disable_parallel_precompile = true
using CrossPackageExtToExtDependency
Base.get_extension(CrossPackageExtToExtDependency.CyclicExtensions, :ExtA) isa Module || error("expected extension to load")
Base.get_extension(CrossPackageExtToExtDependency, :ExtAB) isa Module || error("expected extension to load")
CrossPackageExtToExtDependency.greet()
"""
proj = joinpath(@__DIR__, "project", "Extensions", "CrossPackageExtToExtDependency")
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 x-package ext-to-ext!", String(read(cmd)))
end

finally
try
rm(depot_path, force=true, recursive=true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.11.1"
manifest_format = "2.0"
project_hash = "dc35c2cf8c6b82fb5b9624c9713c2df34ca30499"

[[deps.CyclicExtensions]]
deps = ["ExtDep"]
path = "../CyclicExtensions"
uuid = "17d4f0df-b55c-4714-ac4b-55fa23f7355c"
version = "0.1.0"
weakdeps = ["SomePackage"]

[deps.CyclicExtensions.extensions]
ExtA = ["SomePackage"]
ExtB = ["SomePackage"]

[[deps.ExtDep]]
deps = ["SomeOtherPackage", "SomePackage"]
path = "../ExtDep.jl"
uuid = "fa069be4-f60b-4d4c-8b95-f8008775090c"
version = "0.1.0"

[[deps.SomeOtherPackage]]
path = "../SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
version = "0.1.0"

[[deps.SomePackage]]
path = "../SomePackage"
uuid = "678608ae-7bb3-42c7-98b1-82102067a3d8"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name = "CrossPackageExtToExtDependency"
uuid = "30f07f2e-c47e-40db-93a2-cbc4d1b301cc"
version = "0.1.0"

[deps]
CyclicExtensions = "17d4f0df-b55c-4714-ac4b-55fa23f7355c"

[weakdeps]
SomePackage = "678608ae-7bb3-42c7-98b1-82102067a3d8"

[extensions]
ExtAB = ["CyclicExtensions", "SomePackage"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module ExtAB

using CrossPackageExtToExtDependency
using SomePackage
using CyclicExtensions

const ExtA = Base.get_extension(CyclicExtensions, :ExtA)
if !(ExtA isa Module)
error("expected extension to load")
end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module CrossPackageExtToExtDependency

using CyclicExtensions

greet() = print("Hello x-package ext-to-ext!")

end # module CrossPackageExtToTextDependency
7 changes: 6 additions & 1 deletion test/project/Extensions/CyclicExtensions/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ manifest_format = "2.0"
project_hash = "ec25ff8df3a5e2212a173c3de2c7d716cc47cd36"

[[deps.ExtDep]]
deps = ["SomePackage"]
deps = ["SomePackage", "SomeOtherPackage"]
path = "../ExtDep.jl"
uuid = "fa069be4-f60b-4d4c-8b95-f8008775090c"
version = "0.1.0"
Expand All @@ -15,6 +15,11 @@ path = "../ExtDep2"
uuid = "55982ee5-2ad5-4c40-8cfe-5e9e1b01500d"
version = "0.1.0"

[[deps.SomeOtherPackage]]
path = "../SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
version = "0.1.0"

[[deps.SomePackage]]
path = "../SomePackage"
uuid = "678608ae-7bb3-42c7-98b1-82102067a3d8"
Expand Down
7 changes: 6 additions & 1 deletion test/project/Extensions/EnvWithDeps/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ manifest_format = "2.0"
project_hash = "ec25ff8df3a5e2212a173c3de2c7d716cc47cd36"

[[deps.ExtDep]]
deps = ["SomePackage"]
deps = ["SomePackage", "SomeOtherPackage"]
path = "../ExtDep.jl"
uuid = "fa069be4-f60b-4d4c-8b95-f8008775090c"
version = "0.1.0"
Expand All @@ -15,6 +15,11 @@ path = "../ExtDep2"
uuid = "55982ee5-2ad5-4c40-8cfe-5e9e1b01500d"
version = "0.1.0"

[[deps.SomeOtherPackage]]
path = "../SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
version = "0.1.0"

[[deps.SomePackage]]
path = "../SomePackage"
uuid = "678608ae-7bb3-42c7-98b1-82102067a3d8"
Expand Down
7 changes: 6 additions & 1 deletion test/project/Extensions/EnvWithHasExtensions/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ manifest_format = "2.0"
project_hash = "a4c480cfa7da9610333d5c42623bf746bd286c5f"

[[deps.ExtDep]]
deps = ["SomePackage"]
deps = ["SomePackage", "SomeOtherPackage"]
path = "../ExtDep.jl"
uuid = "fa069be4-f60b-4d4c-8b95-f8008775090c"
version = "0.1.0"
Expand All @@ -25,6 +25,11 @@ version = "0.1.0"
ExtDep2 = "55982ee5-2ad5-4c40-8cfe-5e9e1b01500d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.SomeOtherPackage]]
path = "../SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
version = "0.1.0"

[[deps.SomePackage]]
path = "../SomePackage"
uuid = "678608ae-7bb3-42c7-98b1-82102067a3d8"
Expand Down
7 changes: 6 additions & 1 deletion test/project/Extensions/EnvWithHasExtensionsv2/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ manifest_format = "2.0"
project_hash = "caa716752e6dff3d77c3de929ebbb5d2024d04ef"

[[deps.ExtDep]]
deps = ["SomePackage"]
deps = ["SomePackage", "SomeOtherPackage"]
path = "../ExtDep.jl"
uuid = "fa069be4-f60b-4d4c-8b95-f8008775090c"
version = "0.1.0"
Expand All @@ -19,6 +19,11 @@ weakdeps = ["ExtDep"]
[deps.HasExtensions.extensions]
Extension2 = "ExtDep"

[[deps.SomeOtherPackage]]
path = "../SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
version = "0.1.0"

[[deps.SomePackage]]
path = "../SomePackage"
uuid = "678608ae-7bb3-42c7-98b1-82102067a3d8"
Expand Down
1 change: 1 addition & 0 deletions test/project/Extensions/ExtDep.jl/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ version = "0.1.0"

[deps]
SomePackage = "678608ae-7bb3-42c7-98b1-82102067a3d8"
SomeOtherPackage = "178f68a2-4498-45ee-a775-452b36359b63"
1 change: 1 addition & 0 deletions test/project/Extensions/ExtDep.jl/src/ExtDep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module ExtDep

# loading this package makes the check for loading extensions trigger
# which tests #47921
using SomeOtherPackage
using SomePackage

struct ExtDepStruct end
Expand Down
21 changes: 21 additions & 0 deletions test/project/Extensions/ExtToExtDependency/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.11.1"
manifest_format = "2.0"
project_hash = "90b427e837c654fabb1434527ea698dabad46d29"

[[deps.ExtDep]]
deps = ["SomeOtherPackage", "SomePackage"]
path = "../ExtDep.jl"
uuid = "fa069be4-f60b-4d4c-8b95-f8008775090c"
version = "0.1.0"

[[deps.SomeOtherPackage]]
path = "../SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
version = "0.1.0"

[[deps.SomePackage]]
path = "../SomePackage"
uuid = "678608ae-7bb3-42c7-98b1-82102067a3d8"
version = "0.1.0"
14 changes: 14 additions & 0 deletions test/project/Extensions/ExtToExtDependency/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name = "ExtToExtDependency"
uuid = "594ddb71-72fb-4cfe-9471-775d48a5b70b"
version = "0.1.0"

[deps]
ExtDep = "fa069be4-f60b-4d4c-8b95-f8008775090c"

[weakdeps]
SomeOtherPackage = "178f68a2-4498-45ee-a775-452b36359b63"
SomePackage = "678608ae-7bb3-42c7-98b1-82102067a3d8"

[extensions]
ExtA = ["SomePackage"]
ExtAB = ["SomePackage", "SomeOtherPackage"]
6 changes: 6 additions & 0 deletions test/project/Extensions/ExtToExtDependency/ext/ExtA.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module ExtA

using ExtToExtDependency
using SomePackage

end
12 changes: 12 additions & 0 deletions test/project/Extensions/ExtToExtDependency/ext/ExtAB.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module ExtAB

using ExtToExtDependency
using SomePackage
using SomeOtherPackage

const ExtA = Base.get_extension(ExtToExtDependency, :ExtA)
if !(ExtA isa Module)
error("expected extension to load")
end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module ExtToExtDependency

using ExtDep

greet() = print("Hello ext-to-ext!")

end # module ExtToExtDependency
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ manifest_format = "2.0"
project_hash = "4e196b07f2ee7adc48ac9d528d42b3cf3737c7a0"

[[deps.ExtDep]]
deps = ["SomePackage"]
deps = ["SomePackage", "SomeOtherPackage"]
path = "../ExtDep.jl"
uuid = "fa069be4-f60b-4d4c-8b95-f8008775090c"
version = "0.1.0"
Expand Down Expand Up @@ -37,6 +37,11 @@ version = "0.1.0"
ExtDep2 = "55982ee5-2ad5-4c40-8cfe-5e9e1b01500d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.SomeOtherPackage]]
path = "../SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
version = "0.1.0"

[[deps.SomePackage]]
path = "../SomePackage"
uuid = "678608ae-7bb3-42c7-98b1-82102067a3d8"
Expand Down
4 changes: 4 additions & 0 deletions test/project/Extensions/SomeOtherPackage/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "SomeOtherPackage"
uuid = "178f68a2-4498-45ee-a775-452b36359b63"
authors = ["Cody Tapscott <[email protected]>"]
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module SomeOtherPackage

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

end # module SomeOtherPackage

0 comments on commit 85218bc

Please sign in to comment.