Skip to content

Commit 5bfd116

Browse files
STDLIBS_BY_VERSION: Check sorted & require same minor (#4414)
1 parent ce98612 commit 5bfd116

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Types.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,23 @@ function get_last_stdlibs(julia_version::VersionNumber; use_historical_for_curre
557557
end
558558
historical_stdlibs_check()
559559
last_stdlibs = UNREGISTERED_STDLIBS
560+
last_version = nothing
561+
560562
for (version, stdlibs) in STDLIBS_BY_VERSION
563+
if !isnothing(last_version) && last_version > version
564+
pkgerror("STDLIBS_BY_VERSION must be sorted by version number")
565+
end
561566
if VersionNumber(julia_version.major, julia_version.minor, julia_version.patch) < version
562567
break
563568
end
564569
last_stdlibs = stdlibs
570+
last_version = version
565571
end
572+
# Serving different patches is safe-ish, but different majors or minors is most likely not.
573+
if last_version !== nothing && (last_version.major != julia_version.major || last_version.minor != julia_version.minor)
574+
pkgerror("Could not find a julia version in STDLIBS_BY_VERSION that matches the major & minor version of requested julia_version v$(julia_version)")
575+
end
576+
566577
return last_stdlibs
567578
end
568579
# If `julia_version` is set to `nothing`, that means (essentially) treat all registered

test/historical_stdlib_version.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ using .Utils
3131
@test is_stdlib(pkg_uuid)
3232
@test is_stdlib(pkg_uuid, v"1.0")
3333
@test is_stdlib(pkg_uuid, v"1.6")
34-
@test is_stdlib(pkg_uuid, v"999.999.999")
3534
@test is_stdlib(pkg_uuid, v"0.7")
3635
@test is_stdlib(pkg_uuid, nothing)
3736

37+
# We can't serve information for unknown major.minor versions (patches can not match)
38+
@test_throws Pkg.Types.PkgError is_stdlib(pkg_uuid, v"999.999.999")
39+
@test is_stdlib(pkg_uuid, v"1.10.999")
40+
3841
# MbedTLS_jll stopped being a stdlib in 1.12
3942
@test !is_stdlib(mbedtls_jll_uuid)
4043
@test !is_stdlib(mbedtls_jll_uuid, v"1.12")

0 commit comments

Comments
 (0)