Skip to content

Commit

Permalink
increase isolation of test
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Aug 5, 2018
1 parent d5890e6 commit fee0392
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions stdlib/Pkg/test/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,41 @@ module APITests

using Pkg, Test

include("utils.jl")

@testset "Pkg.activate" begin
cd(mktempdir()) do
path = pwd()
Pkg.activate(".")
mkdir("Foo")
cd(mkdir("modules")) do
Pkg.generate("Foo")
temp_pkg_dir() do project_path
cd(mktempdir()) do
path = pwd()
Pkg.activate(".")
mkdir("Foo")
cd(mkdir("modules")) do
Pkg.generate("Foo")
end
Pkg.develop(Pkg.Types.PackageSpec(path="modules/Foo")) # to avoid issue #542
Pkg.activate("Foo") # activate path Foo over deps Foo
@test Base.active_project() == joinpath(path, "Foo", "Project.toml")
Pkg.activate(".")
rm("Foo"; force=true, recursive=true)
Pkg.activate("Foo") # activate path from developed Foo
@test Base.active_project() == joinpath(path, "modules", "Foo", "Project.toml")
Pkg.activate(".")
Pkg.activate("./Foo") # activate empty directory Foo (sidestep the developed Foo)
@test Base.active_project() == joinpath(path, "Foo", "Project.toml")
Pkg.activate(".")
Pkg.activate("Bar") # activate empty directory Bar
@test Base.active_project() == joinpath(path, "Bar", "Project.toml")
Pkg.activate(".")
Pkg.add("Example") # non-deved deps should not be activated
Pkg.activate("Example")
@test Base.active_project() == joinpath(path, "Example", "Project.toml")
Pkg.activate(".")
cd(mkdir("tests"))
Pkg.activate("Foo") # activate developed Foo from another directory
@test Base.active_project() == joinpath(path, "modules", "Foo", "Project.toml")
Pkg.activate() # activate home project
@test Base.ACTIVE_PROJECT[] === nothing
end
Pkg.develop(Pkg.Types.PackageSpec(path="modules/Foo")) # to avoid issue #542
Pkg.activate("Foo") # activate path Foo over deps Foo
@test Base.active_project() == joinpath(path, "Foo", "Project.toml")
Pkg.activate(".")
rm("Foo"; force=true, recursive=true)
Pkg.activate("Foo") # activate path from developed Foo
@test Base.active_project() == joinpath(path, "modules", "Foo", "Project.toml")
Pkg.activate(".")
Pkg.activate("./Foo") # activate empty directory Foo (sidestep the developed Foo)
@test Base.active_project() == joinpath(path, "Foo", "Project.toml")
Pkg.activate(".")
Pkg.activate("Bar") # activate empty directory Bar
@test Base.active_project() == joinpath(path, "Bar", "Project.toml")
Pkg.activate(".")
Pkg.add("Example") # non-deved deps should not be activated
Pkg.activate("Example")
@test Base.active_project() == joinpath(path, "Example", "Project.toml")
Pkg.activate(".")
cd(mkdir("tests"))
Pkg.activate("Foo") # activate developed Foo from another directory
@test Base.active_project() == joinpath(path, "modules", "Foo", "Project.toml")
Pkg.activate() # activate home project
@test Base.ACTIVE_PROJECT[] === nothing
end
end

Expand Down

0 comments on commit fee0392

Please sign in to comment.