Skip to content

Commit

Permalink
Merge branch 'master' into dpa/every-compat-is-dep
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge authored Oct 26, 2024
2 parents 413d53e + fb7ade6 commit a9ef58e
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/registry_testing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Pkg: Pkg
# import GitCommand
using HTTP: HTTP
using RegistryTools: RegistryTools
using Test: Test
using Test: Test, @testset, @test

function gather_stdlib_uuids()
return Set{Base.UUID}(x for x in keys(RegistryTools.stdlibs()))
Expand Down Expand Up @@ -148,7 +148,7 @@ registries elsewhere, then you may provide the github urls for those registries
using the `registry_deps` parameter.
"""
function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
Test.@testset "(Registry|Package|Versions|Deps|Compat).toml" begin
@testset "(Registry|Package|Versions|Deps|Compat).toml" begin
cd(path) do
reg = Pkg.TOML.parsefile("Registry.toml")
reguuids = Set{Base.UUID}(Base.UUID(x) for x in keys(reg["packages"]))
Expand All @@ -158,25 +158,25 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])

# Test that each entry in Registry.toml has a corresponding Package.toml
# at the expected path with the correct uuid and name
Test.@testset "$(get(data, "name", uuid))" for (uuid, data) in reg["packages"]
@testset "$(get(data, "name", uuid))" for (uuid, data) in reg["packages"]
# Package.toml testing
pkg = Pkg.TOML.parsefile(abspath(data["path"], "Package.toml"))
Test.@test Base.UUID(uuid) == Base.UUID(pkg["uuid"])
Test.@test data["name"] == pkg["name"]
Test.@test Base.isidentifier(data["name"])
Test.@test haskey(pkg, "repo")
@test Base.UUID(uuid) == Base.UUID(pkg["uuid"])
@test data["name"] == pkg["name"]
@test Base.isidentifier(data["name"])
@test haskey(pkg, "repo")

# Versions.toml testing
vers = Pkg.TOML.parsefile(abspath(data["path"], "Versions.toml"))
vnums = VersionNumber.(keys(vers))
for (v, data) in vers
Test.@test VersionNumber(v) isa VersionNumber
Test.@test haskey(data, "git-tree-sha1")
@test VersionNumber(v) isa VersionNumber
@test haskey(data, "git-tree-sha1")

# https://github.com/JuliaRegistries/RegistryCI.jl/issues/523
# "yanked" is correct.
# "yank" (and all other variants) are incorrect.
Test.@test keys(data) ["git-tree-sha1", "yanked"]
@test keys(data) ["git-tree-sha1", "yanked"]
end

# Deps.toml testing
Expand All @@ -191,14 +191,14 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
msg = "It is not the case that all dependencies exist in the General registry"
@error msg setdiff(depuuids, alluuids)
end
Test.@test depuuids alluuids
@test depuuids alluuids
# Test that the way Pkg loads this data works
Test.@test load_deps(depsfile, vnums)
@test load_deps(depsfile, vnums)
# Make sure the content roundtrips through decompression/compression
compressed = RegistryTools.Compress.compress(
depsfile, RegistryTools.Compress.load(depsfile)
)
Test.@test _spacify_hyphens(compressed) == _spacify_hyphens(deps)
@test _spacify_hyphens(compressed) == _spacify_hyphens(deps)
else
@debug "Deps.toml file does not exist" depsfile
end
Expand Down Expand Up @@ -228,16 +228,16 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
# Make sure that each compat spec is a valid registry compat spec.
# https://github.com/JuliaRegistries/General/issues/104849
for (versionrange, compatinfo) in pairs(compat)
Test.@test Pkg.Types.VersionRange(versionrange) isa Pkg.Types.VersionRange
@test Pkg.Types.VersionRange(versionrange) isa Pkg.Types.VersionRange
for (name, spec_unparsed) in pairs(compatinfo)
spec = Pkg.Types.VersionSpec(spec_unparsed)
# Make sure that the compat spec is a valid registry compat spec:
Test.@test spec isa Pkg.Types.VersionSpec
@test spec isa Pkg.Types.VersionSpec
end
end

# Test that the way Pkg loads this data works
Test.@test load_compat(compatfile, vnums)
@test load_compat(compatfile, vnums)
# Make sure the content roundtrips through decompression/compression.
# However, before we check for equality, we change the compat ranges
# from `String`s to `VersionRanges`.
Expand All @@ -247,7 +247,7 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
mapvalues = (f, dict) -> Dict(k => f(v) for (k, v) in dict)
f_inner = v -> Pkg.Types.VersionRange.(v)
f_outer = dict -> mapvalues(f_inner, dict)
Test.@test _spacify_hyphens(mapvalues(f_outer, compressed)) == _spacify_hyphens(mapvalues(f_outer, compat))
@test _spacify_hyphens(mapvalues(f_outer, compressed)) == _spacify_hyphens(mapvalues(f_outer, compat))
else
@debug "Compat.toml file does not exist" compatfile
end
Expand Down Expand Up @@ -303,7 +303,7 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
joinpath(lowercase.(x[1:i])...) for
x in path_parts if get(x, i, nothing) !== nothing
)
Test.@test length(i_parts) == length(i_parts′)
@test length(i_parts) == length(i_parts′)
end
end
end
Expand Down

0 comments on commit a9ef58e

Please sign in to comment.