Skip to content

Commit eba00a2

Browse files
committed
add test for #52161
1 parent 5e8ea59 commit eba00a2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/relocatedepot.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,41 @@ if !test_relocated_depot
9393
end
9494
end
9595

96+
@testset "#52161" begin
97+
# Take the src file from the precompiled RelocationTestPkg1, which is located in depot1, and
98+
# add it as an include_dependency() to a new pkg Foo, which will be precompiled into depot2.
99+
# Foo should be fully relocatable and the include_dependency() should refer to depot1.
100+
pkgname = "Foo"
101+
test_harness() do
102+
# make RelocationTestPkg1 loadable
103+
depot1 = @__DIR__
104+
push!(LOAD_PATH, depot1)
105+
push!(DEPOT_PATH, depot1)
106+
# precompile Foo into another depot
107+
mktempdir() do depot2
108+
pushfirst!(LOAD_PATH, depot2)
109+
pushfirst!(DEPOT_PATH, depot2)
110+
foofile = joinpath(depot2, "Foo.jl")
111+
write(foofile, """
112+
module Foo
113+
using RelocationTestPkg1
114+
srcfile = joinpath(pkgdir(RelocationTestPkg1), "src", "RelocationTestPkg1.jl")
115+
@show srcfile
116+
include_dependency(srcfile)
117+
end
118+
""")
119+
pkg = Base.identify_package(pkgname)
120+
Base.require(pkg)
121+
cachefile = joinpath(depot2, "compiled", "v1.11", "Foo.ji")
122+
_, (deps, _, _), _... = Base.parse_cache_header(cachefile)
123+
@test map(x -> x.filename, deps) ==
124+
[ joinpath(depot2, "Foo.jl"),
125+
joinpath(depot1, "RelocationTestPkg1", "src", "RelocationTestPkg1.jl") ]
126+
end
127+
end
128+
end
129+
130+
96131
else
97132

98133
@testset "load stdlib from test/relocatedepot" begin

0 commit comments

Comments
 (0)