Skip to content

Commit eefedfd

Browse files
authored
Try #1361:
2 parents 6c978c0 + 58634b9 commit eefedfd

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

src/Artifacts.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ Ensures an artifact is installed, downloading it via the download information st
778778
function ensure_artifact_installed(name::String, artifacts_toml::String;
779779
platform::Platform = platform_key_abi(),
780780
pkg_uuid::Union{Base.UUID,Nothing}=nothing)
781-
meta = artifact_meta(name, artifacts_toml; pkg_uuid=pkg_uuid)
781+
meta = artifact_meta(name, artifacts_toml; pkg_uuid=pkg_uuid, platform=platform)
782782
if meta === nothing
783783
error("Cannot locate artifact '$(name)' in '$(artifacts_toml)'")
784784
end

src/versions.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,12 @@ subset of the pool of available versions, this function computes a `VersionSpec`
262262
includes all versions in `subset` and none of the versions in its complement.
263263
"""
264264
function compress_versions(pool::Vector{VersionNumber}, subset::Vector{VersionNumber})
265-
subset = sort(subset) # must copy, we mutate this
265+
# Explicitly drop prerelease/build numbers, as those can confuse this.
266+
# TODO: Rewrite all this to use VersionNumbers instead of VersionBounds
267+
drop_build_prerelease(v::VersionNumber) = VersionNumber(v.major, v.minor, v.patch)
268+
pool = drop_build_prerelease.(pool)
269+
subset = sort!(drop_build_prerelease.(subset))
270+
266271
complement = sort!(setdiff(pool, subset))
267272
ranges = VersionRange[]
268273
@label again

test/artifacts.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ end
272272
bind_artifact!(artifacts_toml, "foo_txt", hash; download_info=download_info, platform=Windows(:i686))
273273
@test artifact_hash("foo_txt", artifacts_toml; platform=Linux(:x86_64)) == hash2
274274
@test artifact_hash("foo_txt", artifacts_toml; platform=Windows(:i686)) == hash
275+
@test ensure_artifact_installed("foo_txt", artifacts_toml; platform=Linux(:x86_64)) == artifact_path(hash2)
276+
@test ensure_artifact_installed("foo_txt", artifacts_toml; platform=Windows(:i686)) == artifact_path(hash)
275277

276278
# Next, check that we can get the download_info properly:
277279
meta = artifact_meta("foo_txt", artifacts_toml; platform=Windows(:i686))

test/pkg.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,32 @@ import Pkg.Types: semver_spec, VersionSpec
9595
@test !(Pkg.Types.isjoinable(Pkg.Types.VersionBound((1,5)), Pkg.Types.VersionBound((1,6,0))))
9696
end
9797

98+
@testset "compress_versions()" begin
99+
# Test exact version matching
100+
vs = [v"1.1.0", v"1.1.1", v"1.1.2"]
101+
@test Pkg.Types.compress_versions(vs, [vs[2]]) == Pkg.Types.VersionSpec("1.1.1")
102+
103+
# Test holes
104+
vs = [v"1.1.0", v"1.1.1", v"1.1.4"]
105+
@test Pkg.Types.compress_versions(vs, [vs[2]]) == Pkg.Types.VersionSpec("1.1.1")
106+
107+
# Test patch variation with length(subset) > 1
108+
vs = [v"1.1.0", v"1.1.1", v"1.1.2", v"1.1.3", v"1.2.0"]
109+
@test Pkg.Types.compress_versions(vs, [vs[2], vs[3]]) == Pkg.Types.VersionSpec("1.1.1-1.1.2")
110+
111+
# Test minor variation
112+
vs = [v"1.1.0", v"1.1.1", v"1.2.0"]
113+
@test Pkg.Types.compress_versions(vs, [vs[2]]) == Pkg.Types.VersionSpec("1.1.1-1.1")
114+
115+
# Test major variation
116+
vs = [v"1.1.0", v"1.1.1", v"1.2.0", v"2.0.0"]
117+
@test Pkg.Types.compress_versions(vs, [vs[2], vs[3]]) == Pkg.Types.VersionSpec("1.1.1-1")
118+
119+
# Test build numbers and prerelease values are ignored
120+
vs = [v"1.1.0-alpha", v"1.1.0+0", v"1.1.0+1"]
121+
@test Pkg.Types.compress_versions(vs, [vs[2]]) == Pkg.Types.VersionSpec("1")
122+
end
123+
98124
# TODO: Should rewrite these tests not to rely on internals like field names
99125
@testset "union, isjoinable" begin
100126
@test sprint(print, VersionRange("0-0.3.2")) == "0-0.3.2"

0 commit comments

Comments
 (0)