Skip to content

Commit d29b365

Browse files
committed
relocation test: tune load_path/depot_path setup to better exercise functionality
1 parent 7e0e7d4 commit d29b365

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ relocatedepot:
4343
@cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot
4444
@cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot
4545
@cd $(SRCDIR) && \
46-
$(call PRINT_JULIA, $(call spawn,JULIA_DEBUG=loading RELOCATEDEPOT="" JULIA_DEPOT_PATH=$(SRCDIR)/relocatedepot/julia $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)
46+
$(call PRINT_JULIA, $(call spawn,JULIA_DEBUG=loading RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)
4747

4848
revise-relocatedepot: revise-% :
4949
@rm -rf $(SRCDIR)/relocatedepot
@@ -54,7 +54,7 @@ revise-relocatedepot: revise-% :
5454
@cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot
5555
@cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot
5656
@cd $(SRCDIR) && \
57-
$(call PRINT_JULIA, $(call spawn,JULIA_DEBUG=loading RELOCATEDEPOT="" JULIA_DEPOT_PATH=$(SRCDIR)/relocatedepot/julia $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)
57+
$(call PRINT_JULIA, $(call spawn,JULIA_DEBUG=loading RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)
5858

5959
embedding:
6060
@$(MAKE) -C $(SRCDIR)/$@ check $(EMBEDDING_ARGS)

test/relocatedepot.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ using Logging
55
include("testenv.jl")
66

77

8-
function test_harness(@nospecialize(fn))
8+
function test_harness(@nospecialize(fn); empty_load_path=true, empty_depot_path=true)
99
load_path = copy(LOAD_PATH)
1010
depot_path = copy(DEPOT_PATH)
1111
try
12+
empty_load_path && empty!(LOAD_PATH)
13+
empty_depot_path && empty!(DEPOT_PATH)
1214
fn()
1315
finally
1416
copy!(LOAD_PATH, load_path)
@@ -66,9 +68,9 @@ if !test_relocated_depot
6668

6769
@testset "precompile RelocationTestPkg1" begin
6870
pkgname = "RelocationTestPkg1"
69-
test_harness() do
71+
test_harness(empty_depot_path=false) do
7072
push!(LOAD_PATH, @__DIR__)
71-
push!(DEPOT_PATH, @__DIR__)
73+
push!(DEPOT_PATH, @__DIR__) # required to make relocatable, but cache is written to DEPOT_PATH[1]
7274
pkg = Base.identify_package(pkgname)
7375
cachefiles = Base.find_all_in_cache_path(pkg)
7476
rm.(cachefiles, force=true)
@@ -80,9 +82,9 @@ if !test_relocated_depot
8082

8183
@testset "precompile RelocationTestPkg2 (contains include_dependency)" begin
8284
pkgname = "RelocationTestPkg2"
83-
test_harness() do
85+
test_harness(empty_depot_path=false) do
8486
push!(LOAD_PATH, @__DIR__)
85-
push!(DEPOT_PATH, string(@__DIR__, "/"))
87+
push!(DEPOT_PATH, @__DIR__) # required to make relocatable, but cache is written to DEPOT_PATH[1]
8688
pkg = Base.identify_package(pkgname)
8789
cachefiles = Base.find_all_in_cache_path(pkg)
8890
rm.(cachefiles, force=true)
@@ -179,8 +181,8 @@ else
179181

180182
@testset "load stdlib from test/relocatedepot" begin
181183
test_harness() do
182-
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot"))
183-
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot"))
184+
push!(LOAD_PATH, "@stdlib")
185+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia"))
184186
# stdlib should be already precompiled
185187
pkg = Base.identify_package("DelimitedFiles")
186188
@test Base.isprecompiled(pkg) == true
@@ -191,7 +193,8 @@ else
191193
pkgname = "RelocationTestPkg1"
192194
test_harness() do
193195
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot"))
194-
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot"))
196+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files
197+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file
195198
pkg = Base.identify_package(pkgname)
196199
@test Base.isprecompiled(pkg) == true
197200
Base.require(pkg) # re-precompile
@@ -203,7 +206,8 @@ else
203206
pkgname = "RelocationTestPkg2"
204207
test_harness() do
205208
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot"))
206-
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot"))
209+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files
210+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file
207211
pkg = Base.identify_package(pkgname)
208212
@test Base.isprecompiled(pkg) == false # moving depot changes mtime of include_dependency
209213
Base.require(pkg) # re-precompile

0 commit comments

Comments
 (0)