-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathpkgrepl.jl
80 lines (72 loc) · 2.25 KB
/
pkgrepl.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
# The functions in CondaPkg.PkgREPL are not API
# but calling them is the closest thing to calling
# the Pkg REPL.
@testitem "add/rm package" begin
include("setup.jl")
CondaPkg.PkgREPL.add(["six==1.16.0"])
@test occursin("six", status())
@test occursin("(==1.16.0)", status())
CondaPkg.PkgREPL.rm(["six"])
@test !occursin("six", status())
end
@testitem "add/rm channel" begin
include("setup.jl")
CondaPkg.PkgREPL.channel_add(["numba"])
@test occursin("numba", status())
CondaPkg.PkgREPL.channel_rm(["numba"])
@test !occursin("numba", status())
end
@testitem "add/rm pip package" begin
include("setup.jl")
CondaPkg.PkgREPL.pip_add(["six==1.16.0", "pydantic[email]==2.9.2"])
@test occursin("six", status())
@test occursin("(==1.16.0)", status())
@test occursin("pydantic", status())
@test occursin("(==2.9.2, [email])", status())
CondaPkg.PkgREPL.pip_rm(["six", "pydantic"])
@test !occursin("six", status())
@test !occursin("pydantic", status())
end
@testitem "status" begin
include("setup.jl")
# TODO: capture the output and check it equals status()
CondaPkg.PkgREPL.status()
end
@testitem "resolve" begin
include("setup.jl")
CondaPkg.PkgREPL.resolve()
@test CondaPkg.is_resolved()
end
@testitem "update" begin
include("setup.jl")
CondaPkg.PkgREPL.update()
@test CondaPkg.is_resolved()
end
@testitem "gc" begin
include("setup.jl")
testgc && CondaPkg.PkgREPL.gc()
@test true
end
@testitem "run" begin
include("setup.jl")
if !isnull
CondaPkg.add("python", version = "==3.10.2")
fn = tempname()
# run python --version and check the output
open(fn, "w") do io
redirect_stdout(io) do
CondaPkg.PkgREPL.run(["python", "--version"])
end
end
@test contains(read(fn, String), "3.10.2")
# run conda --help and check the output
# tests that conda and mamba both run whatever CondaPkg runs
open(fn, "w") do io
redirect_stdout(io) do
CondaPkg.PkgREPL.run([ispixi ? "pixi" : "conda", "--help"])
end
end
@test contains(read(fn, String), "--help")
@test contains(read(fn, String), "--version")
end
end