Skip to content

Commit 720a1ea

Browse files
committed
add RelocationTestPkg4 test
1 parent 178d1e3 commit 720a1ea

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

test/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/libccalltest.*
55
/relocatedepot
66
/RelocationTestPkg2/src/foo.txt
7+
/RelocationTestPkg*/Manifest.toml

test/Makefile

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

@@ -55,6 +56,7 @@ revise-relocatedepot: revise-% :
5556
@cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot
5657
@cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot
5758
@cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot
59+
@cp -R $(SRCDIR)/RelocationTestPkg4 $(SRCDIR)/relocatedepot
5860
@cd $(SRCDIR) && \
5961
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*)
6062

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name = "RelocationTestPkg4"
2+
uuid = "d423d817-d7e9-49ac-b245-9d9d6db0b429"
3+
version = "0.1.0"
4+
5+
[deps]
6+
RelocationTestPkg1 = "854e1adb-5a97-46bf-a391-1cfe05ac726d"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module RelocationTestPkg4
2+
3+
greet() = print("Hello World!")
4+
5+
end # module RelocationTestPkg4

test/relocatedepot.jl

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ function test_harness(@nospecialize(fn); empty_load_path=true, empty_depot_path=
1717
end
1818
end
1919

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
2426

2527
if !test_relocated_depot
2628

@@ -123,6 +125,23 @@ if !test_relocated_depot
123125
end
124126
end
125127

128+
@testset "precompile RelocationTestPkg4" begin
129+
# test for #52346 and https://github.com/JuliaLang/julia/issues/53859#issuecomment-2027352004
130+
# If a pkgimage is not relocatable, no repeated precompilation should occur.
131+
pkgname = "RelocationTestPkg4"
132+
test_harness(empty_depot_path=false) do
133+
push!(LOAD_PATH, @__DIR__)
134+
# skip this dir to make the pkgimage not relocatable
135+
filter!(!=(@__DIR__), DEPOT_PATH)
136+
pkg = Base.identify_package(pkgname)
137+
cachefiles = Base.find_all_in_cache_path(pkg)
138+
rm.(cachefiles, force=true)
139+
@test Base.isprecompiled(pkg) == false
140+
Base.require(pkg)
141+
@test Base.isprecompiled(pkg, ignore_loaded=true) == true
142+
end
143+
end
144+
126145
@testset "#52161" begin
127146
# Take the src files from two pkgs Example1 and Example2,
128147
# which are each located in depot1 and depot2, respectively, and
@@ -246,7 +265,7 @@ else
246265
pkgname = "RelocationTestPkg3"
247266
test_harness() do
248267
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot"))
249-
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot"))
268+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files
250269
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file
251270
pkg = Base.identify_package(pkgname)
252271
@test Base.isprecompiled(pkg) == true
@@ -257,4 +276,16 @@ else
257276
end
258277
end
259278

279+
@testset "load RelocationTestPkg4 from test/relocatedepot" begin
280+
pkgname = "RelocationTestPkg4"
281+
test_harness() do
282+
push!(LOAD_PATH, @__DIR__, "relocatedepot")
283+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files
284+
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file
285+
pkg = Base.identify_package(pkgname)
286+
# precompiled but not relocatable
287+
@test Base.isprecompiled(pkg) == true
288+
end
289+
end
290+
260291
end

0 commit comments

Comments
 (0)