Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"]
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)
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
72 changes: 37 additions & 35 deletions test/automerge-unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ const AutoMerge = RegistryCI.AutoMerge
# disable the Pkg server.
ENV["JULIA_PKG_SERVER"] = ""

@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.
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
import BrokenRecord
end

@testset "RegistryCI.jl" begin
@testset "RegistryCI.jl unit tests" begin
@info("Running the RegistryCI.jl unit tests")
Expand Down