From eba00a20b06115f88a5a1188fb66acf107410f56 Mon Sep 17 00:00:00 2001 From: Florian Atteneder Date: Sat, 6 Jan 2024 14:20:40 +0100 Subject: [PATCH] add test for #52161 --- test/relocatedepot.jl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/relocatedepot.jl b/test/relocatedepot.jl index e326920527b93a..fc83343f112666 100644 --- a/test/relocatedepot.jl +++ b/test/relocatedepot.jl @@ -93,6 +93,41 @@ if !test_relocated_depot end end + @testset "#52161" begin + # Take the src file from the precompiled RelocationTestPkg1, which is located in depot1, and + # add it as an include_dependency() to a new pkg Foo, which will be precompiled into depot2. + # Foo should be fully relocatable and the include_dependency() should refer to depot1. + pkgname = "Foo" + test_harness() do + # make RelocationTestPkg1 loadable + depot1 = @__DIR__ + push!(LOAD_PATH, depot1) + push!(DEPOT_PATH, depot1) + # precompile Foo into another depot + mktempdir() do depot2 + pushfirst!(LOAD_PATH, depot2) + pushfirst!(DEPOT_PATH, depot2) + foofile = joinpath(depot2, "Foo.jl") + write(foofile, """ + module Foo + using RelocationTestPkg1 + srcfile = joinpath(pkgdir(RelocationTestPkg1), "src", "RelocationTestPkg1.jl") + @show srcfile + include_dependency(srcfile) + end + """) + pkg = Base.identify_package(pkgname) + Base.require(pkg) + cachefile = joinpath(depot2, "compiled", "v1.11", "Foo.ji") + _, (deps, _, _), _... = Base.parse_cache_header(cachefile) + @test map(x -> x.filename, deps) == + [ joinpath(depot2, "Foo.jl"), + joinpath(depot1, "RelocationTestPkg1", "src", "RelocationTestPkg1.jl") ] + end + end + end + + else @testset "load stdlib from test/relocatedepot" begin