Skip to content

Commit 79d7881

Browse files
committed
add RelocationTestPkg4 test
1 parent fc55f54 commit 79d7881

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

test/RelocationTestPkg4/Project.toml

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

@@ -117,6 +119,23 @@ if !test_relocated_depot
117119
end
118120
end
119121

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+
120139
@testset "#52161" begin
121140
# Take the src files from two pkgs Example1 and Example2,
122141
# which are each located in depot1 and depot2, respectively, and
@@ -235,7 +254,7 @@ else
235254
pkgname = "RelocationTestPkg3"
236255
test_harness() do
237256
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
239258
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file
240259
pkg = Base.identify_package(pkgname)
241260
@test Base.isprecompiled(pkg) == true
@@ -244,4 +263,16 @@ else
244263
end
245264
end
246265

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+
247278
end

0 commit comments

Comments
 (0)