Skip to content

Commit

Permalink
Merge #514
Browse files Browse the repository at this point in the history
514: Registry consistency tests: before doing certain equality comparisons, add whitespace before and after hyphens r=DilumAluthge a=DilumAluthge

This is necessary due to JuliaLang/Pkg.jl#3580, which made it onto Julia master in JuliaLang/julia#51186.

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
  • Loading branch information
bors[bot] and DilumAluthge committed Oct 16, 2023
2 parents 9957688 + f287ed2 commit f6c4a89
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
RegistryCI = "0c95cc5f-2f7e-43fe-82dd-79dbcba86b32"

[compat]
Documenter = "< 1"
24 changes: 22 additions & 2 deletions src/registry_testing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
compressed = RegistryTools.Compress.compress(
depsfile, RegistryTools.Compress.load(depsfile)
)
Test.@test compressed == deps
Test.@test _spacify_hyphens(compressed) == _spacify_hyphens(deps)
else
@debug "Deps.toml file does not exist" depsfile
end
Expand Down Expand Up @@ -229,7 +229,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 mapvalues(f_outer, compressed) == mapvalues(f_outer, compat)
Test.@test _spacify_hyphens(mapvalues(f_outer, compressed)) == _spacify_hyphens(mapvalues(f_outer, compat))
else
@debug "Compat.toml file does not exist" compatfile
end
Expand All @@ -251,3 +251,23 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
end
return nothing
end

# Change all occurences of "digit-digit" to "digit - digit"
function _spacify_hyphens(str::AbstractString)
r = r"(\d)-(\d)"
s = s"\1 - \2"
new_str = replace(str, r => s)
end

# Apply `_spacify_hyphens()` recursively through a dictionary
function _spacify_hyphens(dict::Dict{K, V}) where {K, V}
new_dict = Dict{K, V}()
for (k, v) in pairs(dict)
new_k = _spacify_hyphens(k)
new_v = _spacify_hyphens(v)
end
return new_dict
end

_spacify_hyphens(range::Pkg.Types.VersionRange) = range
_spacify_hyphens(ranges::Vector{Pkg.Types.VersionRange}) = ranges

0 comments on commit f6c4a89

Please sign in to comment.