Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix STDLIBS_BY_VERSION on non-latest version of Julia #2491

Merged
merged 1 commit into from
Apr 6, 2021
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
24 changes: 14 additions & 10 deletions src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,19 @@ function stdlibs()
end
is_stdlib(uuid::UUID) = uuid in keys(stdlibs())

# Find the entry in `STDLIBS_BY_VERSION`
# that corresponds to the requested version, and use that.
function get_last_stdlibs(julia_version::VersionNumber)
last_stdlibs = Dict{UUID,String}()
for (version, stdlibs) in STDLIBS_BY_VERSION
if VersionNumber(julia_version.major, julia_version.minor, julia_version.patch) < version
break
end
last_stdlibs = stdlibs
end
return last_stdlibs
end

# Allow asking if something is an stdlib for a particular version of Julia
function is_stdlib(uuid::UUID, julia_version::Union{VersionNumber, Nothing})
# Only use the cache if we are asking for stdlibs in a custom Julia version
Expand All @@ -388,16 +401,7 @@ function is_stdlib(uuid::UUID, julia_version::Union{VersionNumber, Nothing})
return false
end

# If we are given an actual version, find the entry in `STDLIBS_BY_VERSION`
# that corresponds to the requested version, and use that.
last_stdlibs = Dict{UUID,String}()
for (version, stdlibs) in STDLIBS_BY_VERSION
if VersionNumber(julia_version.major, julia_version.minor, julia_version.patch) < version
break
end
last_stdlibs = stdlibs
end

last_stdlibs = get_last_stdlibs(julia_version)
# Note that if the user asks for something like `julia_version = 0.7.0`, we'll
# fall through with an empty `last_stdlibs`, which will always return `false`.
return uuid in keys(last_stdlibs)
Expand Down
9 changes: 5 additions & 4 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2603,12 +2603,13 @@ using Pkg.Types: is_stdlib
end

@testset "STDLIBS_BY_VERSION up-to-date" begin
test_result = Pkg.Types.STDLIBS_BY_VERSION[end][2] == Pkg.Types.load_stdlib()
last_stdlibs = Pkg.Types.get_last_stdlibs(VERSION)
test_result = last_stdlibs == Pkg.Types.load_stdlib()
if !test_result
@error("STDLIBS_BY_VERSION out of date! Manually fix given the info below, or re-run generate_historical_stdlibs.jl!")
@show length(Pkg.Types.STDLIBS_BY_VERSION[end][2]) length(Pkg.Types.load_stdlib())
@show setdiff(Pkg.Types.STDLIBS_BY_VERSION[end][2], Pkg.Types.load_stdlib())
@show setdiff(Pkg.Types.load_stdlib(), Pkg.Types.STDLIBS_BY_VERSION[end][2])
@show length(last_stdlibs) length(Pkg.Types.load_stdlib())
@show setdiff(last_stdlibs, Pkg.Types.load_stdlib())
@show setdiff(Pkg.Types.load_stdlib(), last_stdlibs)
end
@test test_result
end
Expand Down