From 5460497bf4e2f22fda1a8a42b4b2abfe5e6eaf06 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Wed, 6 Sep 2023 16:12:33 -0400 Subject: [PATCH 01/11] Registry consistency tests: before doing certain equality comparisons, add whitespace before and after hyphens --- src/registry_testing.jl | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/registry_testing.jl b/src/registry_testing.jl index f5ca7b06..d18936da 100644 --- a/src/registry_testing.jl +++ b/src/registry_testing.jl @@ -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 @@ -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 @@ -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 From 765f7978fd4a5dd93853fd73d67d0707c81338a8 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:00:01 -0400 Subject: [PATCH 02/11] Fix Documenter --- docs/Project.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/Project.toml b/docs/Project.toml index 6bd3cb7f..12087b01 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,3 +1,6 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" RegistryCI = "0c95cc5f-2f7e-43fe-82dd-79dbcba86b32" + +[compat] +Documenter = "< 1" From 135cc414223be2b5195b1fed76560fb465713cc3 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:28:07 -0400 Subject: [PATCH 03/11] BrokenRecord fails to precompile on Julia 1.11 --- Project.toml | 4 +--- test/runtests.jl | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 612b7e4e..fca0bbc6 100644 --- a/Project.toml +++ b/Project.toml @@ -24,7 +24,6 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" VisualStringDistances = "089bb0c6-1854-47b9-96f7-327dbbe09dca" [compat] -BrokenRecord = "0.1.3" GitHub = "5.2" HTTP = "0.8, 0.9.1, 1" JSON = "0.19, 0.20, 0.21" @@ -39,7 +38,6 @@ VisualStringDistances = "0.1" julia = "1.3" [extras] -BrokenRecord = "bdd55f5b-6e67-4da1-a080-6086e55655a0" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" @@ -50,4 +48,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" [targets] -test = ["BrokenRecord", "Dates", "GitHub", "JSON", "Pkg", "Printf", "SimpleMock", "Test", "TimeZones"] +test = ["Dates", "GitHub", "JSON", "Pkg", "Printf", "SimpleMock", "Test", "TimeZones"] diff --git a/test/runtests.jl b/test/runtests.jl index 26018ffd..b682293f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,6 +16,16 @@ const AutoMerge = RegistryCI.AutoMerge # disable the Pkg server. ENV["JULIA_PKG_SERVER"] = "" +@static if Base.VERSION < v"1.11" + # BrokenRecord fails to precompile on Julia 1.11 + Pkg.add(; + name = "BrokenRecord", + uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", + version = "0.1.3", + ) + import BrokenRecord +end + @testset "RegistryCI.jl" begin @testset "RegistryCI.jl unit tests" begin @info("Running the RegistryCI.jl unit tests") From 402ca8167239e6cc2b05de20005a50a1534f5a20 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:33:54 -0400 Subject: [PATCH 04/11] Use BrokenRecord 0.1.9 --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index b682293f..07878c5a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -21,7 +21,7 @@ ENV["JULIA_PKG_SERVER"] = "" Pkg.add(; name = "BrokenRecord", uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", - version = "0.1.3", + version = "0.1.9", ) import BrokenRecord end From 193cb13ca081f5e4355242e06958f370fc095aee Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:39:25 -0400 Subject: [PATCH 05/11] Fix some Pkg syntax for older Julia versions --- test/runtests.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 07878c5a..9d6d8199 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,10 +18,12 @@ ENV["JULIA_PKG_SERVER"] = "" @static if Base.VERSION < v"1.11" # BrokenRecord fails to precompile on Julia 1.11 - Pkg.add(; - name = "BrokenRecord", - uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", - version = "0.1.9", + Pkg.add( + Pkg.PackageSpec(; + name = "BrokenRecord", + uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", + version = "0.1.9", + ) ) import BrokenRecord end From fef523624332b5386443d4085869d557c3a5da63 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:44:12 -0400 Subject: [PATCH 06/11] Specify the versions of both BrokenRecord and JLD2 --- test/runtests.jl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 9d6d8199..1463bef4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,13 +18,12 @@ ENV["JULIA_PKG_SERVER"] = "" @static if Base.VERSION < v"1.11" # BrokenRecord fails to precompile on Julia 1.11 - Pkg.add( - Pkg.PackageSpec(; - name = "BrokenRecord", - uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", - version = "0.1.9", - ) - ) + let + brokenrecord = Pkg.PackageSpec(name = "BrokenRecord", uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", version = "0.1.9") + jld2 = Pkg.PackageSpec(name = "JLD2", uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819", version = "0.4.33") + pkgs = [brokenrecord, jld2] + Pkg.add(pkgs) + end import BrokenRecord end From 029b562e361c7b043a96779652a731fac154cede Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:50:53 -0400 Subject: [PATCH 07/11] Only install BrokenRecord as a test dep on Julia 1.6 through Julia 1.10 (inclusive) --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 1463bef4..b6d783df 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,7 +16,7 @@ const AutoMerge = RegistryCI.AutoMerge # disable the Pkg server. ENV["JULIA_PKG_SERVER"] = "" -@static if Base.VERSION < v"1.11" +@static if v"1.6-" <= Base.VERSION < v"1.11" # BrokenRecord fails to precompile on Julia 1.11 let brokenrecord = Pkg.PackageSpec(name = "BrokenRecord", uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", version = "0.1.9") From 333b2109589b14cddb6e2d52c5b94060cfe3bec8 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:52:50 -0400 Subject: [PATCH 08/11] When installing the BrokenRecord test dep, install the exact version --- test/runtests.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index b6d783df..45e26ef5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -19,8 +19,9 @@ ENV["JULIA_PKG_SERVER"] = "" @static if v"1.6-" <= Base.VERSION < v"1.11" # BrokenRecord fails to precompile on Julia 1.11 let - brokenrecord = Pkg.PackageSpec(name = "BrokenRecord", uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", version = "0.1.9") - jld2 = Pkg.PackageSpec(name = "JLD2", uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819", version = "0.4.33") + # The use of `VersionNumber`s here (e.g. `version = v"foo.bar.baz"`) tells Pkg to install the exact version. + brokenrecord = Pkg.PackageSpec(name = "BrokenRecord", uuid = "bdd55f5b-6e67-4da1-a080-6086e55655a0", version = v"0.1.9") + jld2 = Pkg.PackageSpec(name = "JLD2", uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819", version = v"0.4.33") pkgs = [brokenrecord, jld2] Pkg.add(pkgs) end From 6531a77853322f3bbe878db8857a967583968c2f Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Mon, 16 Oct 2023 00:04:38 -0400 Subject: [PATCH 09/11] Fix a version specifier --- test/runtests.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 45e26ef5..00878980 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,7 +16,7 @@ const AutoMerge = RegistryCI.AutoMerge # disable the Pkg server. ENV["JULIA_PKG_SERVER"] = "" -@static if v"1.6-" <= Base.VERSION < v"1.11" +@static if v"1.6-" <= Base.VERSION < v"1.11-" # BrokenRecord fails to precompile on Julia 1.11 let # The use of `VersionNumber`s here (e.g. `version = v"foo.bar.baz"`) tells Pkg to install the exact version. From 5d7092e40f4b77a9b21c2cd3ad23d7828915f243 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Thu, 19 Oct 2023 12:28:28 -0400 Subject: [PATCH 10/11] Try to fix a test --- test/automerge-unit.jl | 72 ++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/test/automerge-unit.jl b/test/automerge-unit.jl index 7166da50..6d844e47 100644 --- a/test/automerge-unit.jl +++ b/test/automerge-unit.jl @@ -601,41 +601,43 @@ end end @testset "`AutoMerge.meets_version_has_osi_license`" begin - # Let's install a fresh depot in a temporary directory - # and add some packages to inspect. - tmp_depot = setup_global_depot() - function has_osi_license_in_depot(pkg) - return AutoMerge.meets_version_has_osi_license( - pkg; pkg_code_path=pkgdir_from_depot(tmp_depot, pkg) - ) - end - # Let's test ourselves and some of our dependencies that just have MIT licenses: - result = has_osi_license_in_depot("RegistryCI") - @test result[1] - result = has_osi_license_in_depot("UnbalancedOptimalTransport") - @test result[1] - result = has_osi_license_in_depot("VisualStringDistances") - @test result[1] - - # Now, what happens if there's also a non-OSI license in another file? - pkg_path = pkgdir_from_depot(tmp_depot, "UnbalancedOptimalTransport") - open(joinpath(pkg_path, "LICENSE2"); write=true) do io - cc0_bytes = read(joinpath(@__DIR__, "license_data", "CC0.txt")) - println(io) - write(io, cc0_bytes) + withenv("JULIA_PKG_PRECOMPILE_AUTO" => "0") do + # Let's install a fresh depot in a temporary directory + # and add some packages to inspect. + tmp_depot = setup_global_depot() + function has_osi_license_in_depot(pkg) + return AutoMerge.meets_version_has_osi_license( + pkg; pkg_code_path=pkgdir_from_depot(tmp_depot, pkg) + ) + end + # Let's test ourselves and some of our dependencies that just have MIT licenses: + result = has_osi_license_in_depot("RegistryCI") + @test result[1] + result = has_osi_license_in_depot("UnbalancedOptimalTransport") + @test result[1] + result = has_osi_license_in_depot("VisualStringDistances") + @test result[1] + + # Now, what happens if there's also a non-OSI license in another file? + pkg_path = pkgdir_from_depot(tmp_depot, "UnbalancedOptimalTransport") + open(joinpath(pkg_path, "LICENSE2"); write=true) do io + cc0_bytes = read(joinpath(@__DIR__, "license_data", "CC0.txt")) + println(io) + write(io, cc0_bytes) + end + result = has_osi_license_in_depot("UnbalancedOptimalTransport") + @test result[1] + + # What if we also remove the original license, leaving only the CC0 license? + rm(joinpath(pkg_path, "LICENSE")) + result = has_osi_license_in_depot("UnbalancedOptimalTransport") + @test !result[1] + + # What about no license at all? + pkg_path = pkgdir_from_depot(tmp_depot, "VisualStringDistances") + rm(joinpath(pkg_path, "LICENSE")) + result = has_osi_license_in_depot("VisualStringDistances") + @test !result[1] end - result = has_osi_license_in_depot("UnbalancedOptimalTransport") - @test result[1] - - # What if we also remove the original license, leaving only the CC0 license? - rm(joinpath(pkg_path, "LICENSE")) - result = has_osi_license_in_depot("UnbalancedOptimalTransport") - @test !result[1] - - # What about no license at all? - pkg_path = pkgdir_from_depot(tmp_depot, "VisualStringDistances") - rm(joinpath(pkg_path, "LICENSE")) - result = has_osi_license_in_depot("VisualStringDistances") - @test !result[1] end end From 079676b5c0cb737a9be238bf1206f6129bbf222f Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sun, 15 Oct 2023 23:32:17 -0400 Subject: [PATCH 11/11] `pairs()` is not necessary when iterating over a `Base.Dict` --- src/registry_testing.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/registry_testing.jl b/src/registry_testing.jl index d18936da..98565b63 100644 --- a/src/registry_testing.jl +++ b/src/registry_testing.jl @@ -262,7 +262,12 @@ 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) + # Note: `Base.Dict` iterates key-value pairs, so it's sufficient for us to do + # `for (k, v) in dict`. However, there are some other dictionary implementations + # (such as the Dictionaries.jl package) that do not iterate key-value pairs. So, + # if we ever decide to widen the type signature of this method, we'll need to + # change `(k, v) in dict` to `(k, v) in pairs(dict)`. + for (k, v) in dict new_k = _spacify_hyphens(k) new_v = _spacify_hyphens(v) end