@@ -17,10 +17,12 @@ function test_harness(@nospecialize(fn); empty_load_path=true, empty_depot_path=
17
17
end
18
18
end
19
19
20
- # We test relocation with three dummy pkgs:
21
- # - RelocationTestPkg1 - no include_dependency
22
- # - RelocationTestPkg2 - with include_dependency tracked by `mtime`
23
- # - RelocationTestPkg3 - with include_dependency tracked by content
20
+ # We test relocation with these dummy pkgs:
21
+ # - RelocationTestPkg1 - pkg with no include_dependency
22
+ # - RelocationTestPkg2 - pkg with include_dependency tracked by `mtime`
23
+ # - RelocationTestPkg3 - pkg with include_dependency tracked by content
24
+ # - RelocationTestPkg4 - pkg with no dependencies; will be compiled such that the pkgimage is
25
+ # not relocatable, but no repeated recompilation happens upon loading
24
26
25
27
if ! test_relocated_depot
26
28
@@ -117,6 +119,23 @@ if !test_relocated_depot
117
119
end
118
120
end
119
121
122
+ @testset " precompile RelocationTestPkg4" begin
123
+ # test for #52346 and https://github.com/JuliaLang/julia/issues/53859#issuecomment-2027352004
124
+ # If a pkgimage is not relocatable, no repeated precompilation should occur.
125
+ pkgname = " RelocationTestPkg4"
126
+ test_harness (empty_depot_path= false ) do
127
+ push! (LOAD_PATH , @__DIR__ )
128
+ # skip this dir to make the pkgimage not relocatable
129
+ filter! (!= (@__DIR__ ), DEPOT_PATH )
130
+ pkg = Base. identify_package (pkgname)
131
+ cachefiles = Base. find_all_in_cache_path (pkg)
132
+ rm .(cachefiles, force= true )
133
+ @test Base. isprecompiled (pkg) == false
134
+ Base. require (pkg)
135
+ @test Base. isprecompiled (pkg, ignore_loaded= true ) == true
136
+ end
137
+ end
138
+
120
139
@testset " #52161" begin
121
140
# Take the src files from two pkgs Example1 and Example2,
122
141
# which are each located in depot1 and depot2, respectively, and
235
254
pkgname = " RelocationTestPkg3"
236
255
test_harness () do
237
256
push! (LOAD_PATH , joinpath (@__DIR__ , " relocatedepot" ))
238
- push! (DEPOT_PATH , joinpath (@__DIR__ , " relocatedepot" ))
257
+ push! (DEPOT_PATH , joinpath (@__DIR__ , " relocatedepot" )) # required to find src files
239
258
push! (DEPOT_PATH , joinpath (@__DIR__ , " relocatedepot" , " julia" )) # contains cache file
240
259
pkg = Base. identify_package (pkgname)
241
260
@test Base. isprecompiled (pkg) == true
@@ -244,4 +263,16 @@ else
244
263
end
245
264
end
246
265
266
+ @testset " load RelocationTestPkg4 from test/relocatedepot" begin
267
+ pkgname = " RelocationTestPkg4"
268
+ test_harness () do
269
+ push! (LOAD_PATH , @__DIR__ , " relocatedepot" )
270
+ push! (DEPOT_PATH , joinpath (@__DIR__ , " relocatedepot" )) # required to find src files
271
+ push! (DEPOT_PATH , joinpath (@__DIR__ , " relocatedepot" , " julia" )) # contains cache file
272
+ pkg = Base. identify_package (pkgname)
273
+ # precompiled but not relocatable
274
+ @test Base. isprecompiled (pkg) == true
275
+ end
276
+ end
277
+
247
278
end
0 commit comments