@@ -5,10 +5,12 @@ using Logging
55include (" 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 )
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
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
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