Skip to content

Commit

Permalink
add RelocationTestPkg4 test
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed Mar 30, 2024
1 parent fc55f54 commit 79d7881
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/libccalltest.*
/relocatedepot
/RelocationTestPkg2/src/foo.txt
/RelocationTestPkg*/Manifest.toml
2 changes: 2 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ relocatedepot:
@cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot
@cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot
@cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot
@cp -R $(SRCDIR)/RelocationTestPkg4 $(SRCDIR)/relocatedepot
@cd $(SRCDIR) && \
$(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@)

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

Expand Down
6 changes: 6 additions & 0 deletions test/RelocationTestPkg4/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = "RelocationTestPkg4"
uuid = "d423d817-d7e9-49ac-b245-9d9d6db0b429"
version = "0.1.0"

[deps]
RelocationTestPkg1 = "854e1adb-5a97-46bf-a391-1cfe05ac726d"
5 changes: 5 additions & 0 deletions test/RelocationTestPkg4/src/RelocationTestPkg4.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module RelocationTestPkg4

greet() = print("Hello World!")

end # module RelocationTestPkg4
41 changes: 36 additions & 5 deletions test/relocatedepot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ function test_harness(@nospecialize(fn); empty_load_path=true, empty_depot_path=
end
end

# We test relocation with three dummy pkgs:
# - RelocationTestPkg1 - no include_dependency
# - RelocationTestPkg2 - with include_dependency tracked by `mtime`
# - RelocationTestPkg3 - with include_dependency tracked by content
# We test relocation with these dummy pkgs:
# - RelocationTestPkg1 - pkg with no include_dependency
# - RelocationTestPkg2 - pkg with include_dependency tracked by `mtime`
# - RelocationTestPkg3 - pkg with include_dependency tracked by content
# - RelocationTestPkg4 - pkg with no dependencies; will be compiled such that the pkgimage is
# not relocatable, but no repeated recompilation happens upon loading

if !test_relocated_depot

Expand Down Expand Up @@ -117,6 +119,23 @@ if !test_relocated_depot
end
end

@testset "precompile RelocationTestPkg4" begin
# test for #52346 and https://github.com/JuliaLang/julia/issues/53859#issuecomment-2027352004
# If a pkgimage is not relocatable, no repeated precompilation should occur.
pkgname = "RelocationTestPkg4"
test_harness(empty_depot_path=false) do
push!(LOAD_PATH, @__DIR__)
# skip this dir to make the pkgimage not relocatable
filter!(!=(@__DIR__), DEPOT_PATH)
pkg = Base.identify_package(pkgname)
cachefiles = Base.find_all_in_cache_path(pkg)
rm.(cachefiles, force=true)
@test Base.isprecompiled(pkg) == false
Base.require(pkg)
@test Base.isprecompiled(pkg, ignore_loaded=true) == true
end
end

@testset "#52161" begin
# Take the src files from two pkgs Example1 and Example2,
# which are each located in depot1 and depot2, respectively, and
Expand Down Expand Up @@ -235,7 +254,7 @@ else
pkgname = "RelocationTestPkg3"
test_harness() do
push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot"))
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot"))
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file
pkg = Base.identify_package(pkgname)
@test Base.isprecompiled(pkg) == true
Expand All @@ -244,4 +263,16 @@ else
end
end

@testset "load RelocationTestPkg4 from test/relocatedepot" begin
pkgname = "RelocationTestPkg4"
test_harness() do
push!(LOAD_PATH, @__DIR__, "relocatedepot")
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) # required to find src files
push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot", "julia")) # contains cache file
pkg = Base.identify_package(pkgname)
# precompiled but not relocatable
@test Base.isprecompiled(pkg) == true
end
end

end

0 comments on commit 79d7881

Please sign in to comment.