Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/julia-1.11/activate_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function activate(pkg::AbstractString=current_pkg_name(); allow_reresolve=true)
# Signature changed when workspaces were introduced to Pkg in v1.12 (see Pkg.jl#3841)
subgraph = Pkg.Operations.prune_manifest(sandbox_manifest, VERSION < v"1.12.0-" ? [uuid] : Set([uuid]))
for (uuid, entry) in subgraph
if haskey(working_manifest, uuid)
entry_working = get(working_manifest, uuid, nothing)
if entry_working !== nothing && entry_working != entry && (ctx.env.pkg !== nothing && ctx.env.pkg.uuid != uuid)
Pkg.Operations.pkgerror("can not merge projects")
end
working_manifest[uuid] = entry
Expand Down
3 changes: 2 additions & 1 deletion src/julia-1.13/activate_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function activate(pkg::AbstractString=current_pkg_name(); allow_reresolve=true)
# Signature changed when workspaces were introduced to Pkg in v1.12 (see Pkg.jl#3841)
subgraph = Pkg.Operations.prune_manifest(sandbox_manifest, VERSION < v"1.12.0-" ? [uuid] : Set([uuid]))
for (uuid, entry) in subgraph
if haskey(working_manifest, uuid)
entry_working = get(working_manifest, uuid, nothing)
if entry_working !== nothing && entry_working != entry && (ctx.env.pkg !== nothing && ctx.env.pkg.uuid != uuid)
Pkg.Operations.pkgerror("can not merge projects")
end
working_manifest[uuid] = entry
Expand Down
20 changes: 20 additions & 0 deletions test/activate_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,24 @@
end
end
end

if VERSION >= v"1.12-"
@testset "activate [workspace] test env" 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", "WorkspaceTestEnv"))
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 WorkspaceTestEnv
@test isdefined(@__MODULE__, :WorkspaceTestEnv)
@test WorkspaceTestEnv.foo() == 42
finally
Pkg.activate(orig_project_toml_path)
end
end
end
end
6 changes: 6 additions & 0 deletions test/sources/WorkspaceTestEnv/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = "WorkspaceTestEnv"
uuid = "f7f074d6-898f-4820-8a1f-11e53eb7425f"
version = "0.0.0"

[workspace]
projects = ["test"]
5 changes: 5 additions & 0 deletions test/sources/WorkspaceTestEnv/src/WorkspaceTestEnv.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module WorkspaceTestEnv

foo() = 42

end
3 changes: 3 additions & 0 deletions test/sources/WorkspaceTestEnv/test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
WorkspaceTestEnv = "f7f074d6-898f-4820-8a1f-11e53eb7425f"
4 changes: 4 additions & 0 deletions test/sources/WorkspaceTestEnv/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using WorkspaceTestEnv
using Test

@test WorkspaceTestEnv.foo() == 42
Loading