Skip to content

Commit d68567d

Browse files
Merge #514
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 <[email protected]>
2 parents 9957688 + 5d7092e commit d68567d

File tree

5 files changed

+75
-40
lines changed

5 files changed

+75
-40
lines changed

Project.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
2424
VisualStringDistances = "089bb0c6-1854-47b9-96f7-327dbbe09dca"
2525

2626
[compat]
27-
BrokenRecord = "0.1.3"
2827
GitHub = "5.2"
2928
HTTP = "0.8, 0.9.1, 1"
3029
JSON = "0.19, 0.20, 0.21"
@@ -39,7 +38,6 @@ VisualStringDistances = "0.1"
3938
julia = "1.3"
4039

4140
[extras]
42-
BrokenRecord = "bdd55f5b-6e67-4da1-a080-6086e55655a0"
4341
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
4442
GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26"
4543
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
@@ -50,4 +48,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5048
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
5149

5250
[targets]
53-
test = ["BrokenRecord", "Dates", "GitHub", "JSON", "Pkg", "Printf", "SimpleMock", "Test", "TimeZones"]
51+
test = ["Dates", "GitHub", "JSON", "Pkg", "Printf", "SimpleMock", "Test", "TimeZones"]

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
RegistryCI = "0c95cc5f-2f7e-43fe-82dd-79dbcba86b32"
4+
5+
[compat]
6+
Documenter = "< 1"

src/registry_testing.jl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
193193
compressed = RegistryTools.Compress.compress(
194194
depsfile, RegistryTools.Compress.load(depsfile)
195195
)
196-
Test.@test compressed == deps
196+
Test.@test _spacify_hyphens(compressed) == _spacify_hyphens(deps)
197197
else
198198
@debug "Deps.toml file does not exist" depsfile
199199
end
@@ -229,7 +229,7 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
229229
mapvalues = (f, dict) -> Dict(k => f(v) for (k, v) in dict)
230230
f_inner = v -> Pkg.Types.VersionRange.(v)
231231
f_outer = dict -> mapvalues(f_inner, dict)
232-
Test.@test mapvalues(f_outer, compressed) == mapvalues(f_outer, compat)
232+
Test.@test _spacify_hyphens(mapvalues(f_outer, compressed)) == _spacify_hyphens(mapvalues(f_outer, compat))
233233
else
234234
@debug "Compat.toml file does not exist" compatfile
235235
end
@@ -251,3 +251,23 @@ function test(path=pwd(); registry_deps::Vector{<:AbstractString}=String[])
251251
end
252252
return nothing
253253
end
254+
255+
# Change all occurences of "digit-digit" to "digit - digit"
256+
function _spacify_hyphens(str::AbstractString)
257+
r = r"(\d)-(\d)"
258+
s = s"\1 - \2"
259+
new_str = replace(str, r => s)
260+
end
261+
262+
# Apply `_spacify_hyphens()` recursively through a dictionary
263+
function _spacify_hyphens(dict::Dict{K, V}) where {K, V}
264+
new_dict = Dict{K, V}()
265+
for (k, v) in pairs(dict)
266+
new_k = _spacify_hyphens(k)
267+
new_v = _spacify_hyphens(v)
268+
end
269+
return new_dict
270+
end
271+
272+
_spacify_hyphens(range::Pkg.Types.VersionRange) = range
273+
_spacify_hyphens(ranges::Vector{Pkg.Types.VersionRange}) = ranges

test/automerge-unit.jl

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -601,41 +601,43 @@ end
601601
end
602602

603603
@testset "`AutoMerge.meets_version_has_osi_license`" begin
604-
# Let's install a fresh depot in a temporary directory
605-
# and add some packages to inspect.
606-
tmp_depot = setup_global_depot()
607-
function has_osi_license_in_depot(pkg)
608-
return AutoMerge.meets_version_has_osi_license(
609-
pkg; pkg_code_path=pkgdir_from_depot(tmp_depot, pkg)
610-
)
611-
end
612-
# Let's test ourselves and some of our dependencies that just have MIT licenses:
613-
result = has_osi_license_in_depot("RegistryCI")
614-
@test result[1]
615-
result = has_osi_license_in_depot("UnbalancedOptimalTransport")
616-
@test result[1]
617-
result = has_osi_license_in_depot("VisualStringDistances")
618-
@test result[1]
619-
620-
# Now, what happens if there's also a non-OSI license in another file?
621-
pkg_path = pkgdir_from_depot(tmp_depot, "UnbalancedOptimalTransport")
622-
open(joinpath(pkg_path, "LICENSE2"); write=true) do io
623-
cc0_bytes = read(joinpath(@__DIR__, "license_data", "CC0.txt"))
624-
println(io)
625-
write(io, cc0_bytes)
604+
withenv("JULIA_PKG_PRECOMPILE_AUTO" => "0") do
605+
# Let's install a fresh depot in a temporary directory
606+
# and add some packages to inspect.
607+
tmp_depot = setup_global_depot()
608+
function has_osi_license_in_depot(pkg)
609+
return AutoMerge.meets_version_has_osi_license(
610+
pkg; pkg_code_path=pkgdir_from_depot(tmp_depot, pkg)
611+
)
612+
end
613+
# Let's test ourselves and some of our dependencies that just have MIT licenses:
614+
result = has_osi_license_in_depot("RegistryCI")
615+
@test result[1]
616+
result = has_osi_license_in_depot("UnbalancedOptimalTransport")
617+
@test result[1]
618+
result = has_osi_license_in_depot("VisualStringDistances")
619+
@test result[1]
620+
621+
# Now, what happens if there's also a non-OSI license in another file?
622+
pkg_path = pkgdir_from_depot(tmp_depot, "UnbalancedOptimalTransport")
623+
open(joinpath(pkg_path, "LICENSE2"); write=true) do io
624+
cc0_bytes = read(joinpath(@__DIR__, "license_data", "CC0.txt"))
625+
println(io)
626+
write(io, cc0_bytes)
627+
end
628+
result = has_osi_license_in_depot("UnbalancedOptimalTransport")
629+
@test result[1]
630+
631+
# What if we also remove the original license, leaving only the CC0 license?
632+
rm(joinpath(pkg_path, "LICENSE"))
633+
result = has_osi_license_in_depot("UnbalancedOptimalTransport")
634+
@test !result[1]
635+
636+
# What about no license at all?
637+
pkg_path = pkgdir_from_depot(tmp_depot, "VisualStringDistances")
638+
rm(joinpath(pkg_path, "LICENSE"))
639+
result = has_osi_license_in_depot("VisualStringDistances")
640+
@test !result[1]
626641
end
627-
result = has_osi_license_in_depot("UnbalancedOptimalTransport")
628-
@test result[1]
629-
630-
# What if we also remove the original license, leaving only the CC0 license?
631-
rm(joinpath(pkg_path, "LICENSE"))
632-
result = has_osi_license_in_depot("UnbalancedOptimalTransport")
633-
@test !result[1]
634-
635-
# What about no license at all?
636-
pkg_path = pkgdir_from_depot(tmp_depot, "VisualStringDistances")
637-
rm(joinpath(pkg_path, "LICENSE"))
638-
result = has_osi_license_in_depot("VisualStringDistances")
639-
@test !result[1]
640642
end
641643
end

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ const AutoMerge = RegistryCI.AutoMerge
1616
# disable the Pkg server.
1717
ENV["JULIA_PKG_SERVER"] = ""
1818

19+
@static if v"1.6-" <= Base.VERSION < v"1.11-"
20+
# BrokenRecord fails to precompile on Julia 1.11
21+
let
22+
# The use of `VersionNumber`s here (e.g. `version = v"foo.bar.baz"`) tells Pkg to install the exact version.
23+
brokenrecord = Pkg.PackageSpec(name = "BrokenRecord", uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", version = v"0.1.9")
24+
jld2 = Pkg.PackageSpec(name = "JLD2", uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819", version = v"0.4.33")
25+
pkgs = [brokenrecord, jld2]
26+
Pkg.add(pkgs)
27+
end
28+
import BrokenRecord
29+
end
30+
1931
@testset "RegistryCI.jl" begin
2032
@testset "RegistryCI.jl unit tests" begin
2133
@info("Running the RegistryCI.jl unit tests")

0 commit comments

Comments
 (0)