Skip to content

Commit

Permalink
add test for #52161
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed Jan 6, 2024
1 parent 84a4772 commit edb66b8
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/relocatedepot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,58 @@ if !test_relocated_depot
end
end

@testset "#52161" begin
# Take the src files from two RelocationTestPkg1 and RelocationTestPkg2,
# which are each located in depot1 and depot2, respectively, and
# add them as include_dependency()s to a new pkg Foo, which will be precompiled into depot3.
# After loading the include_dependency()s of Foo should refer to depot1 depot2 each.
test_harness() do
mktempdir() do depot1
# precompile RelocationTestPkg1 in depot1
cp(joinpath(@__DIR__,"RelocationTestPkg1"),joinpath(depot1,"RelocationTestPkg1"))
pushfirst!(LOAD_PATH, depot1)
pushfirst!(DEPOT_PATH, depot1)
pkg = Base.identify_package("RelocationTestPkg1")
Base.require(pkg)
mktempdir() do depot2
cp(joinpath(@__DIR__,"RelocationTestPkg2"),joinpath(depot2,"RelocationTestPkg2"))
# precompile RelocationTestPkg2 in depot2
pushfirst!(LOAD_PATH, depot2)
pushfirst!(DEPOT_PATH, depot2)
pkg = Base.identify_package("RelocationTestPkg2")
Base.require(pkg)
# precompile Foo into in depot3
mktempdir() do depot3
pushfirst!(LOAD_PATH, depot3)
pushfirst!(DEPOT_PATH, depot3)
foofile = joinpath(depot3, "Foo.jl")
write(foofile, """
module Foo
using RelocationTestPkg1
using RelocationTestPkg2
srcfile1 = joinpath(pkgdir(RelocationTestPkg1), "src", "RelocationTestPkg1.jl")
srcfile2 = joinpath(pkgdir(RelocationTestPkg2), "src", "RelocationTestPkg2.jl")
@show srcfile1
@show srcfile2
include_dependency(srcfile1)
include_dependency(srcfile2)
end
""")
pkg = Base.identify_package("Foo")
Base.require(pkg)
cachefile = joinpath(depot3, "compiled", "v1.11", "Foo.ji")
_, (deps, _, _), _... = Base.parse_cache_header(cachefile)
@test map(x -> x.filename, deps) ==
[ joinpath(depot3, "Foo.jl"),
joinpath(depot1, "RelocationTestPkg1", "src", "RelocationTestPkg1.jl"),
joinpath(depot2, "RelocationTestPkg2", "src", "RelocationTestPkg2.jl") ]
end
end
end
end
end


else

@testset "load stdlib from test/relocatedepot" begin
Expand Down

0 comments on commit edb66b8

Please sign in to comment.