Skip to content

Commit

Permalink
Add tests for partial Pkg.update()
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobaldassi committed Jul 11, 2016
1 parent de490f6 commit 719822c
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ macro grab_outputs(ex)
end

# Test basic operations: adding or removing a package, status, free
#Also test for the existence of REQUIRE and META_Branch
# Also test for the existence of REQUIRE and META_BRANCH
temp_pkg_dir() do
@test isfile(joinpath(Pkg.dir(),"REQUIRE"))
@test isfile(joinpath(Pkg.dir(),"META_BRANCH"))
Expand Down Expand Up @@ -398,4 +398,73 @@ temp_pkg_dir() do
@test contains(msg, "$package is not an installed package")
@test !contains(msg, "signal (15)")
end

# partial Pkg.update
begin
nothingtodomsg = "INFO: No packages to install, update or remove\n"

ret, out, err = @grab_outputs begin
Pkg.rm("Example")
Pkg.add("Example")
end
@test ret == nothing && out == ""
@test contains(err, "INFO: Installing Example v")

ret, out, err = @grab_outputs Pkg.update("Example")
@test ret == nothing && out == ""
@test contains(err, nothingtodomsg)

ret, out, err = @grab_outputs begin
Pkg.rm("Example")
Pkg.add("Example", v"0", v"0.4.1-")
end
@test ret == nothing && out == ""
@test contains(err, "INFO: Installing Example v0.4.0")

ret, out, err = @grab_outputs Pkg.update("Example")
@test ret == nothing && out == ""
@test ismatch(r"INFO: Package Example was set to version 0\.4\.0, but a higher version \d+\.\d+\.\d+\S* exists.\n", err)
@test contains(err, "The update is prevented by explicit requirements constraints. Edit your REQUIRE file to change this.\n")
@test contains(err, nothingtodomsg)

ret, out, err = @grab_outputs begin
Pkg.rm("Example")
Pkg.add("Example")
Pkg.pin("Example", v"0.4.0")
end
@test ret == nothing && out == ""
@test contains(err, "INFO: Installing Example")

ret, out, err = @grab_outputs Pkg.update("Example")
@test ret == nothing && out == ""
@test contains(err, "INFO: Package Example: skipping update (pinned)...\n")
@test ismatch(r"INFO: Package Example was set to version 0\.4\.0, but a higher version \d+\.\d+\.\d+\S* exists.\n", err)
@test contains(err, "The package is fixed. You can try using `Pkg.free(\"Example\")` to update it.")
@test contains(err, nothingtodomsg)

metadata_dir = joinpath(Pkg.Dir.path(), "METADATA")
const test_commit = "313bfaafa301e82d40574a778720e893c559a7e2"

LibGit2.with(LibGit2. GitRepo, metadata_dir) do repo
LibGit2.reset!(repo, LibGit2.Oid(test_commit), LibGit2.Consts.RESET_HARD)
end

ret, out, err = @grab_outputs Pkg.add("Colors")
@test ret == nothing && out == ""
@test contains(err, "INFO: Installing Colors v0.6.4")
@test contains(err, "INFO: Installing ColorTypes v0.2.2")
@test contains(err, "INFO: Installing FixedPointNumbers v0.1.3")
@test contains(err, "INFO: Installing Compat v0.7.18")
@test contains(err, "INFO: Installing Reexport v0.0.3")

ret, out, err = @grab_outputs Pkg.update("ColorTypes")
@test ismatch(r"INFO: Upgrading ColorTypes: v0\.2\.2 => v\d+\.\d+\.\d+", err)
@test ismatch(r"INFO: Upgrading Compat: v0\.7\.18 => v\d+\.\d+\.\d+", err)
@test !contains(err, "INFO: Upgrading Colors: ")
@test Pkg.installed("Colors") == v"0.6.4"

ret, out, err = @grab_outputs Pkg.update("FixedPointNumbers")
@test ret == nothing && out == ""
@test contains(err, nothingtodomsg)
end
end

0 comments on commit 719822c

Please sign in to comment.