Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port loadpath fix #21

Merged
merged 2 commits into from
Aug 3, 2021
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "TestEnv"
uuid = "1e6cf692-eddd-4d53-88a5-2d735e33781b"
version = "1.8.0"
version = "1.8.0-DEV"

[deps]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
9 changes: 1 addition & 8 deletions src/activate_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ function activate(pkg::AbstractString=current_pkg_name())

Types.write_manifest(working_manifest, tmp_manifest)

# sandbox
push!(empty!(LOAD_PATH), "@", tmp)
Base.ACTIVE_PROJECT[] = nothing
Base.ACTIVE_PROJECT[] = tmp_project

temp_ctx = Context()
temp_ctx.env.project.deps[pkgspec.name] = pkgspec.uuid
Expand All @@ -77,11 +75,6 @@ function activate(pkg::AbstractString=current_pkg_name())
end
end
write_env(temp_ctx.env; update_undo=false)

# update enviroment variables
path_sep = Sys.iswindows() ? ';' : ':'
ENV["JULIA_LOAD_PATH"] = "@$(path_sep)$(tmp)"
delete!(ENV, "JULIA_PROJECT")

return Base.active_project()
end
16 changes: 14 additions & 2 deletions test/activate_set.jl
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
@testset "activate_set.jl" begin
@testset "activate [extras]" 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
TestEnv.activate("ChainRulesCore")
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 StaticArrays
@eval using StaticArrays # From ChainRulesCore [extras] Project.toml
@test isdefined(@__MODULE__, :StaticArrays)

@eval using Compat # from ChainRulesCore Project.toml
@test isdefined(@__MODULE__, :StaticArrays)
finally
Pkg.activate(orig_project_toml_path)
# No longer is enviroment active
@test_throws ArgumentError @eval using OffsetArrays
end
end

@testset "activate test/Project" 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
# YAXArrays has a test/Project.toml, which contains CSV
TestEnv.activate("YAXArrays")
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 CSV
@test isdefined(@__MODULE__, :CSV)

finally
Pkg.activate(orig_project_toml_path)
end
end
end
end