-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathactivate_set.jl
89 lines (77 loc) · 3.55 KB
/
activate_set.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@testset "activate_set.jl" begin
@testset "activate [extras]" begin
mktempdir() do p
Pkg.activate(p)
Pkg.add(PackageSpec(name="ChainRulesCore", version="1.0.2"))
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 # From ChainRulesCore [extras] Project.toml
@test Base.invokelatest(isdefined, @__MODULE__, :StaticArrays)
@eval using Compat # from ChainRulesCore Project.toml
@test Base.invokelatest(isdefined, @__MODULE__, :Compat)
finally
Pkg.activate(orig_project_toml_path)
# No longer is enviroment active
@test_throws ArgumentError @eval using OffsetArrays
end
end
end
@testset "activate test/Project" begin
mktempdir() do p
Pkg.activate(p)
if VERSION >= v"1.4-"
Pkg.add(PackageSpec(name="YAXArrays", version="0.1.3"))
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
if VERSION >= v"1.8-"
kw = (; allow_reresolve=false)
else
kw = NamedTuple()
end
TestEnv.activate("YAXArrays"; kw...)
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 Base.invokelatest(isdefined, @__MODULE__, :CSV)
finally
Pkg.activate(orig_project_toml_path)
end
elseif VERSION >= v"1.2-"
Pkg.add(PackageSpec(name="ConstraintSolver", version="0.6.10"))
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
# ConstraintSolver has a test/Project.toml, which contains CSV
if VERSION >= v"1.8-"
kw = (; allow_reresolve=false)
else
kw = NamedTuple()
end
TestEnv.activate("ConstraintSolver"; kw...)
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 JSON
@test Base.invokelatest(isdefined, @__MODULE__, :JSON)
finally
Pkg.activate(orig_project_toml_path)
end
end
end
if VERSION >= v"1.4-"
# https://github.com/JuliaTesting/TestEnv.jl/issues/26
@test isdefined(TestEnv, :isfixed)
end
end
end