Skip to content

Commit d986ad1

Browse files
authored
Merge pull request #109 from pfitzseb/sp/fix-1-12-test-manifest
fix: allow ./test project merging
2 parents 5be878b + 7a6c58d commit d986ad1

File tree

7 files changed

+42
-2
lines changed

7 files changed

+42
-2
lines changed

src/julia-1.11/activate_set.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function activate(pkg::AbstractString=current_pkg_name(); allow_reresolve=true)
4040
# Signature changed when workspaces were introduced to Pkg in v1.12 (see Pkg.jl#3841)
4141
subgraph = Pkg.Operations.prune_manifest(sandbox_manifest, VERSION < v"1.12.0-" ? [uuid] : Set([uuid]))
4242
for (uuid, entry) in subgraph
43-
if haskey(working_manifest, uuid)
43+
entry_working = get(working_manifest, uuid, nothing)
44+
if entry_working !== nothing && entry_working != entry && (ctx.env.pkg !== nothing && ctx.env.pkg.uuid != uuid)
4445
Pkg.Operations.pkgerror("can not merge projects")
4546
end
4647
working_manifest[uuid] = entry

src/julia-1.13/activate_set.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function activate(pkg::AbstractString=current_pkg_name(); allow_reresolve=true)
4040
# Signature changed when workspaces were introduced to Pkg in v1.12 (see Pkg.jl#3841)
4141
subgraph = Pkg.Operations.prune_manifest(sandbox_manifest, VERSION < v"1.12.0-" ? [uuid] : Set([uuid]))
4242
for (uuid, entry) in subgraph
43-
if haskey(working_manifest, uuid)
43+
entry_working = get(working_manifest, uuid, nothing)
44+
if entry_working !== nothing && entry_working != entry && (ctx.env.pkg !== nothing && ctx.env.pkg.uuid != uuid)
4445
Pkg.Operations.pkgerror("can not merge projects")
4546
end
4647
working_manifest[uuid] = entry

test/activate_set.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,24 @@
123123
end
124124
end
125125
end
126+
127+
if VERSION >= v"1.12-"
128+
@testset "activate [workspace] test env" begin
129+
orig_project_toml_path = Base.active_project()
130+
push!(LOAD_PATH, mktempdir()) # put something weird in LOAD_PATH for testing
131+
orig_load_path = Base.LOAD_PATH
132+
try
133+
Pkg.activate(joinpath(@__DIR__, "sources", "WorkspaceTestEnv"))
134+
TestEnv.activate()
135+
new_project_toml_path = Base.active_project()
136+
@test new_project_toml_path != orig_project_toml_path
137+
@test orig_load_path == Base.LOAD_PATH
138+
@eval using WorkspaceTestEnv
139+
@test isdefined(@__MODULE__, :WorkspaceTestEnv)
140+
@test WorkspaceTestEnv.foo() == 42
141+
finally
142+
Pkg.activate(orig_project_toml_path)
143+
end
144+
end
145+
end
126146
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name = "WorkspaceTestEnv"
2+
uuid = "f7f074d6-898f-4820-8a1f-11e53eb7425f"
3+
version = "0.0.0"
4+
5+
[workspace]
6+
projects = ["test"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module WorkspaceTestEnv
2+
3+
foo() = 42
4+
5+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3+
WorkspaceTestEnv = "f7f074d6-898f-4820-8a1f-11e53eb7425f"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using WorkspaceTestEnv
2+
using Test
3+
4+
@test WorkspaceTestEnv.foo() == 42

0 commit comments

Comments
 (0)