Skip to content

Commit 8a7924a

Browse files
authored
Merge pull request #20 from JuliaTesting/ox/loadpath
Make activate set not mess with LOAD_PATH
2 parents 8d8c90c + 2e57dfb commit 8a7924a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "TestEnv"
22
uuid = "1e6cf692-eddd-4d53-88a5-2d735e33781b"
3-
version = "1.7.0"
3+
version = "1.7.1"
44

55
[deps]
66
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

src/activate_set.jl

+1-8
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ function activate(pkg::AbstractString=current_pkg_name())
4949

5050
Types.write_manifest(working_manifest, tmp_manifest)
5151

52-
# sandbox
53-
push!(empty!(LOAD_PATH), "@", tmp)
54-
Base.ACTIVE_PROJECT[] = nothing
52+
Base.ACTIVE_PROJECT[] = tmp_project
5553

5654
temp_ctx = Context()
5755
temp_ctx.env.project.deps[pkgspec.name] = pkgspec.uuid
@@ -77,11 +75,6 @@ function activate(pkg::AbstractString=current_pkg_name())
7775
end
7876
end
7977
write_env(temp_ctx.env; update_undo=false)
80-
81-
# update enviroment variables
82-
path_sep = Sys.iswindows() ? ';' : ':'
83-
ENV["JULIA_LOAD_PATH"] = "@$(path_sep)$(tmp)"
84-
delete!(ENV, "JULIA_PROJECT")
8578

8679
return Base.active_project()
8780
end

test/activate_set.jl

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
11
@testset "activate_set.jl" begin
22
@testset "activate [extras]" begin
33
orig_project_toml_path = Base.active_project()
4+
push!(LOAD_PATH, mktempdir()) # put something weird in LOAD_PATH for testing
5+
orig_load_path = Base.LOAD_PATH
46
try
57
TestEnv.activate("ChainRulesCore")
68
new_project_toml_path = Base.active_project()
79
@test new_project_toml_path != orig_project_toml_path
10+
@test orig_load_path == Base.LOAD_PATH
811

9-
@eval using StaticArrays
12+
@eval using StaticArrays # From ChainRulesCore [extras] Project.toml
13+
@test isdefined(@__MODULE__, :StaticArrays)
14+
15+
@eval using Compat # from ChainRulesCore Project.toml
1016
@test isdefined(@__MODULE__, :StaticArrays)
1117
finally
1218
Pkg.activate(orig_project_toml_path)
19+
# No longer is enviroment active
20+
@test_throws ArgumentError @eval using OffsetArrays
1321
end
1422
end
1523

1624
@testset "activate test/Project" begin
1725
orig_project_toml_path = Base.active_project()
26+
push!(LOAD_PATH, mktempdir()) # put something weird in LOAD_PATH for testing
27+
orig_load_path = Base.LOAD_PATH
1828
try
1929
# YAXArrays has a test/Project.toml, which contains CSV
2030
TestEnv.activate("YAXArrays")
2131
new_project_toml_path = Base.active_project()
2232
@test new_project_toml_path != orig_project_toml_path
33+
@test orig_load_path == Base.LOAD_PATH
2334

2435
@eval using CSV
2536
@test isdefined(@__MODULE__, :CSV)
37+
2638
finally
2739
Pkg.activate(orig_project_toml_path)
2840
end
2941
end
30-
end
42+
end

0 commit comments

Comments
 (0)