Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Apr 1, 2021
1 parent ec0b05d commit 6a64c9b
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions test/registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function with_depot2(f)
Base.DEPOT_PATH[1:2] .= Base.DEPOT_PATH[2:-1:1]
end


@testset "registries" begin
temp_pkg_dir() do depot; mktempdir() do depot2
insert!(Base.DEPOT_PATH, 2, depot2)
Expand Down Expand Up @@ -320,25 +319,39 @@ end
end
end

@testset "registries" begin
temp_pkg_dir(;) do depot
Pkg.Registry.DEFAULT_REGISTRIES[1].path = nothing
withenv("JULIA_PKG_UNPACK_REGISTRY" => nothing) do
# This should not uncompress the registry
Registry.add(RegistrySpec(uuid = UUID("23338594-aafe-5451-b93e-139f81909106")))
isfile(joinpath(DEPOT_PATH[1], "registries", "General", "General.tar.gz"))
Pkg.add("Example")

# Write some bad git-tree-sha1 here so that Pkg.update will have to update the registry
write(joinpath(DEPOT_PATH[1], "registries", "General", ".registry_info.toml"),
"""
git-tree-sha1 = "179182faa6a80b3cf24445e6f55c954938d57941"
uuid = "23338594-aafe-5451-b93e-139f81909106"
filename = "General.tar.gz"
""")
Pkg.update()
if Pkg.Registry.registry_use_pkg_server()
@testset "compressed registry" begin
for unpack in (true, nothing)
withenv("JULIA_PKG_UNPACK_REGISTRY" => unpack) do
temp_pkg_dir(;linked_reg=false) do depot
# These get restored by temp_pkg_dir
Pkg.Registry.DEFAULT_REGISTRIES[1].path = nothing
Pkg.Registry.DEFAULT_REGISTRIES[1].url = "https://github.com/JuliaRegistries/General.git"

# This should not uncompress the registry
Registry.add(RegistrySpec(uuid = UUID("23338594-aafe-5451-b93e-139f81909106")))
@test isfile(joinpath(DEPOT_PATH[1], "registries", "General", "General.tar.gz")) != something(unpack, false)
Pkg.add("Example")

# Write some bad git-tree-sha1 here so that Pkg.update will have to update the registry
if unpack == true
write(joinpath(DEPOT_PATH[1], "registries", "General", ".tree_info.toml"),
"""
git-tree-sha1 = "179182faa6a80b3cf24445e6f55c954938d57941"
""")
else
write(joinpath(DEPOT_PATH[1], "registries", "General", ".registry_info.toml"),
"""
git-tree-sha1 = "179182faa6a80b3cf24445e6f55c954938d57941"
uuid = "23338594-aafe-5451-b93e-139f81909106"
filename = "General.tar.gz"
""")
end
Pkg.update()
end
end
end
end
end

end # module

0 comments on commit 6a64c9b

Please sign in to comment.