diff --git a/test/Makefile b/test/Makefile index feb424c546cefc..38c5e112fa8e2b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -42,6 +42,7 @@ relocatedepot: @cp -R $(build_datarootdir)/julia $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot + @cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot @cd $(SRCDIR) && \ $(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" JULIA_DEPOT_PATH=$(SRCDIR)/relocatedepot/julia $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl $@) @@ -53,6 +54,7 @@ revise-relocatedepot: revise-% : @cp -R $(build_datarootdir)/julia $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg1 $(SRCDIR)/relocatedepot @cp -R $(SRCDIR)/RelocationTestPkg2 $(SRCDIR)/relocatedepot + @cp -R $(SRCDIR)/RelocationTestPkg3 $(SRCDIR)/relocatedepot @cd $(SRCDIR) && \ $(call PRINT_JULIA, $(call spawn,RELOCATEDEPOT="" JULIA_DEPOT_PATH=$(SRCDIR)/relocatedepot/julia $(JULIA_EXECUTABLE)) --check-bounds=yes --startup-file=no --depwarn=error ./runtests.jl --revise $*) diff --git a/test/RelocationTestPkg3/Project.toml b/test/RelocationTestPkg3/Project.toml new file mode 100644 index 00000000000000..61882cb5cda656 --- /dev/null +++ b/test/RelocationTestPkg3/Project.toml @@ -0,0 +1,3 @@ +name = "RelocationTestPkg3" +uuid = "1ba4f954-9da9-4cd2-9ca7-6250235df52c" +version = "0.1.0" diff --git a/test/RelocationTestPkg3/src/RelocationTestPkg3.jl b/test/RelocationTestPkg3/src/RelocationTestPkg3.jl new file mode 100644 index 00000000000000..6ed8e1e560a997 --- /dev/null +++ b/test/RelocationTestPkg3/src/RelocationTestPkg3.jl @@ -0,0 +1,7 @@ +module RelocationTestPkg3 + +include_dependency("bar.txt", track_content=true) +include_dependency("bardir", track_content=true) +greet() = print("Hello World!") + +end # module RelocationTestPkg3 diff --git a/test/RelocationTestPkg3/src/bar.txt b/test/RelocationTestPkg3/src/bar.txt new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/test/relocatedepot.jl b/test/relocatedepot.jl index f03f76f62ec002..0c6068dc782d7c 100644 --- a/test/relocatedepot.jl +++ b/test/relocatedepot.jl @@ -16,6 +16,10 @@ function test_harness(@nospecialize(fn)) 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 if !test_relocated_depot @@ -28,12 +32,12 @@ if !test_relocated_depot cachefiles = Base.find_all_in_cache_path(pkg) rm.(cachefiles, force=true) @test Base.isprecompiled(pkg) == false - Base.require(pkg) # precompile + Base.require(pkg) @test Base.isprecompiled(pkg, ignore_loaded=true) == true end end - @testset "precompile RelocationTestPkg2 (contains include_dependency)" begin + @testset "precompile RelocationTestPkg2" begin pkgname = "RelocationTestPkg2" test_harness() do push!(LOAD_PATH, @__DIR__) @@ -41,11 +45,28 @@ if !test_relocated_depot pkg = Base.identify_package(pkgname) cachefiles = Base.find_all_in_cache_path(pkg) rm.(cachefiles, force=true) - rm(joinpath(@__DIR__, pkgname, "src", "foodir")) + rm(joinpath(@__DIR__, pkgname, "src", "foodir"), force=true, recursive=true) @test Base.isprecompiled(pkg) == false touch(joinpath(@__DIR__, pkgname, "src", "foo.txt")) mkdir(joinpath(@__DIR__, pkgname, "src", "foodir")) - Base.require(pkg) # precompile + Base.require(pkg) + @test Base.isprecompiled(pkg, ignore_loaded=true) == true + end + end + + @testset "precompile RelocationTestPkg3" begin + pkgname = "RelocationTestPkg3" + test_harness() do + push!(LOAD_PATH, @__DIR__) + push!(DEPOT_PATH, @__DIR__) + pkg = Base.identify_package(pkgname) + cachefiles = Base.find_all_in_cache_path(pkg) + rm.(cachefiles, force=true) + rm(joinpath(@__DIR__, pkgname, "src", "bardir"), force=true, recursive=true) + @test Base.isprecompiled(pkg) == false + touch(joinpath(@__DIR__, pkgname, "src", "bar.txt")) + mkdir(joinpath(@__DIR__, pkgname, "src", "bardir")) + Base.require(pkg) @test Base.isprecompiled(pkg, ignore_loaded=true) == true end end @@ -53,14 +74,13 @@ if !test_relocated_depot else # must come before any of the load tests, because the will recompile and generate new cache files - @testset "attempt loading precompiled pkgs when depot is missing" begin + @testset "attempt loading when depot is missing" begin test_harness() do empty!(LOAD_PATH) push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) - for pkgname in ("RelocationTestPkg1", "RelocationTestPkg2") + for pkgname in ("RelocationTestPkg1", "RelocationTestPkg2", "RelocationTestPkg3") pkg = Base.identify_package(pkgname) cachefile = only(Base.find_all_in_cache_path(pkg)) - @info cachefile @test_throws ArgumentError(""" Failed to determine depot from srctext files in cache file $cachefile. - Make sure you have adjusted DEPOT_PATH in case you relocated depots.""") Base.isprecompiled(pkg) @@ -85,23 +105,33 @@ else push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) pkg = Base.identify_package(pkgname) @test Base.isprecompiled(pkg) == true - Base.require(pkg) # re-precompile - @test Base.isprecompiled(pkg) == true end end - @testset "load RelocationTestPkg2 (contains include_dependency) from test/relocatedepot" begin + @testset "load RelocationTestPkg2 from test/relocatedepot" begin pkgname = "RelocationTestPkg2" test_harness() do push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) pkg = Base.identify_package(pkgname) @test Base.isprecompiled(pkg) == false # moving depot changes mtime of include_dependency - Base.require(pkg) # re-precompile + Base.require(pkg) @test Base.isprecompiled(pkg) == true touch(joinpath(@__DIR__, "relocatedepot", "RelocationTestPkg2", "src", "foodir", "foofoo")) @test Base.isprecompiled(pkg) == false end end + @testset "load RelocationTestPkg3 from test/relocatedepot" begin + pkgname = "RelocationTestPkg3" + test_harness() do + push!(LOAD_PATH, joinpath(@__DIR__, "relocatedepot")) + push!(DEPOT_PATH, joinpath(@__DIR__, "relocatedepot")) + pkg = Base.identify_package(pkgname) + @test Base.isprecompiled(pkg) == true + touch(joinpath(@__DIR__, "relocatedepot", "RelocationTestPkg3", "src", "bardir", "barbar")) + @test Base.isprecompiled(pkg) == false + end + end + end