diff --git a/Project.toml b/Project.toml index d995cd2..6266e5e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "TestEnv" uuid = "1e6cf692-eddd-4d53-88a5-2d735e33781b" -version = "1.102.2" +version = "1.102.3" [deps] Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" diff --git a/src/julia-1.11/activate_set.jl b/src/julia-1.11/activate_set.jl index 3ed050f..5527618 100644 --- a/src/julia-1.11/activate_set.jl +++ b/src/julia-1.11/activate_set.jl @@ -62,8 +62,9 @@ function activate(pkg::AbstractString=current_pkg_name(); allow_reresolve=true) for source in values(temp_ctx.env.project.sources) isa(source, Dict) || continue haskey(source, "path") || continue + base_path = test_dir_has_project_file(temp_ctx, pkgspec) ? joinpath(pkgspec.path, "test") : pkgspec.path if !isabspath(source["path"]) - source["path"] = joinpath(pkgspec.path, source["path"]) + source["path"] = joinpath(base_path, source["path"]) end end diff --git a/test/activate_set.jl b/test/activate_set.jl index 5094da8..89f59a2 100644 --- a/test/activate_set.jl +++ b/test/activate_set.jl @@ -105,5 +105,22 @@ Pkg.activate(orig_project_toml_path) end end + @testset "activate with [sources] and two Project.toml approach" begin + orig_project_toml_path = Base.active_project() + push!(LOAD_PATH, mktempdir()) # put something weird in LOAD_PATH for testing + orig_load_path = Base.LOAD_PATH + try + Pkg.activate(joinpath(@__DIR__, "sources", "MainTestProjectEnv")) + TestEnv.activate() + new_project_toml_path = Base.active_project() + @test new_project_toml_path != orig_project_toml_path + @test orig_load_path == Base.LOAD_PATH + @eval using MainTestProjectEnv + @test isdefined(@__MODULE__, :MainTestProjectEnv) + @test MainTestProjectEnv.bar() == 42 + finally + Pkg.activate(orig_project_toml_path) + end + end end end diff --git a/test/sources/MainTestProjectEnv/Project.toml b/test/sources/MainTestProjectEnv/Project.toml new file mode 100644 index 0000000..9f5d8a5 --- /dev/null +++ b/test/sources/MainTestProjectEnv/Project.toml @@ -0,0 +1,9 @@ +name = "MainTestProjectEnv" +uuid = "e316c70a-63ba-4d10-8c0b-cec00dfd6f7f" +version = "0.0.0" + +[deps] +DependentEnv = "c9261501-a1a4-4a21-a37c-0c7025a0fef8" + +[sources] +DependentEnv = {path = "../DependentEnv"} \ No newline at end of file diff --git a/test/sources/MainTestProjectEnv/src/MainTestProjectEnv.jl b/test/sources/MainTestProjectEnv/src/MainTestProjectEnv.jl new file mode 100644 index 0000000..34ad9cd --- /dev/null +++ b/test/sources/MainTestProjectEnv/src/MainTestProjectEnv.jl @@ -0,0 +1,6 @@ +module MainTestProjectEnv +using DependentEnv + +bar() = DependentEnv.foo() + 2 # Same as in MainEnv + +end diff --git a/test/sources/MainTestProjectEnv/test/Project.toml b/test/sources/MainTestProjectEnv/test/Project.toml new file mode 100644 index 0000000..23e5946 --- /dev/null +++ b/test/sources/MainTestProjectEnv/test/Project.toml @@ -0,0 +1,8 @@ +[deps] +MainEnv = "1b324c26-e66a-4bf4-9aeb-d8ecf06e8e93" +MainTestProjectEnv = "e316c70a-63ba-4d10-8c0b-cec00dfd6f7f" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[sources] +MainTestProjectEnv = {path = ".."} +MainEnv = {path = "../../MainEnv"} \ No newline at end of file diff --git a/test/sources/MainTestProjectEnv/test/runtests.jl b/test/sources/MainTestProjectEnv/test/runtests.jl new file mode 100644 index 0000000..71a9deb --- /dev/null +++ b/test/sources/MainTestProjectEnv/test/runtests.jl @@ -0,0 +1,5 @@ +using MainTestProjectEnv +using MainEnv +using Test + +@test MainTestProjectEnv.bar() == MainEnv.foo()