Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead just strip all white space from both sides? I think that would be less fragile in case there’s other white space changes later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just remove all white space before comparison?

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