Skip to content

Commit b22c725

Browse files
committed
fix STDLIBS_BY_VERSION on non-latest version of Julia
(cherry picked from commit fd1820e)
1 parent 24aad72 commit b22c725

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/Types.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,19 @@ function stdlibs()
363363
end
364364
is_stdlib(uuid::UUID) = uuid in keys(stdlibs())
365365

366+
# Find the entry in `STDLIBS_BY_VERSION`
367+
# that corresponds to the requested version, and use that.
368+
function get_last_stdlibs(julia_version::VersionNumber)
369+
last_stdlibs = Dict{UUID,String}()
370+
for (version, stdlibs) in STDLIBS_BY_VERSION
371+
if VersionNumber(julia_version.major, julia_version.minor, julia_version.patch) < version
372+
break
373+
end
374+
last_stdlibs = stdlibs
375+
end
376+
return last_stdlibs
377+
end
378+
366379
# Allow asking if something is an stdlib for a particular version of Julia
367380
function is_stdlib(uuid::UUID, julia_version::Union{VersionNumber, Nothing})
368381
# Only use the cache if we are asking for stdlibs in a custom Julia version
@@ -381,16 +394,7 @@ function is_stdlib(uuid::UUID, julia_version::Union{VersionNumber, Nothing})
381394
return false
382395
end
383396

384-
# If we are given an actual version, find the entry in `STDLIBS_BY_VERSION`
385-
# that corresponds to the requested version, and use that.
386-
last_stdlibs = Dict{UUID,String}()
387-
for (version, stdlibs) in STDLIBS_BY_VERSION
388-
if VersionNumber(julia_version.major, julia_version.minor, julia_version.patch) < version
389-
break
390-
end
391-
last_stdlibs = stdlibs
392-
end
393-
397+
last_stdlibs = get_last_stdlibs(julia_version)
394398
# Note that if the user asks for something like `julia_version = 0.7.0`, we'll
395399
# fall through with an empty `last_stdlibs`, which will always return `false`.
396400
return uuid in keys(last_stdlibs)

test/new.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,12 +2519,13 @@ using Pkg.Types: is_stdlib
25192519
end
25202520

25212521
@testset "STDLIBS_BY_VERSION up-to-date" begin
2522-
test_result = Pkg.Types.STDLIBS_BY_VERSION[end][2] == Pkg.Types.load_stdlib()
2522+
last_stdlibs = Pkg.Types.get_last_stdlibs(VERSION)
2523+
test_result = last_stdlibs == Pkg.Types.load_stdlib()
25232524
if !test_result
25242525
@error("STDLIBS_BY_VERSION out of date! Manually fix given the info below, or re-run generate_historical_stdlibs.jl!")
2525-
@show length(Pkg.Types.STDLIBS_BY_VERSION[end][2]) length(Pkg.Types.load_stdlib())
2526-
@show setdiff(Pkg.Types.STDLIBS_BY_VERSION[end][2], Pkg.Types.load_stdlib())
2527-
@show setdiff(Pkg.Types.load_stdlib(), Pkg.Types.STDLIBS_BY_VERSION[end][2])
2526+
@show length(last_stdlibs) length(Pkg.Types.load_stdlib())
2527+
@show setdiff(last_stdlibs, Pkg.Types.load_stdlib())
2528+
@show setdiff(Pkg.Types.load_stdlib(), last_stdlibs)
25282529
end
25292530
@test test_result
25302531
end

0 commit comments

Comments
 (0)