Skip to content

Commit 2c00530

Browse files
committed
Fix reset_timelines!()
This was not tested, let's actually test it now and ensure it doesn't break in the future.
1 parent 2ea46a6 commit 2c00530

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Universes.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,16 @@ function registry_package_lookup(f::Function, u::Universe, pkg_name::String, pkg
285285
pkg_uuid = only(pkg_uuids)
286286
pkg_subpath = joinpath(reg_inst.pkgs[pkg_uuid].path, pkg_file)
287287

288-
pkg_data = Pkg.Registry.parsefile(reg_inst, pkg_subpath)
288+
# `parsefile()` does not gracefully deal with missing files, so we catch
289+
# errors here and just skip over missing files.
290+
pkg_data = try
291+
Pkg.Registry.parsefile(reg_inst, pkg_subpath)
292+
catch e
293+
if !isa(e, SystemError)
294+
rethrow(e)
295+
end
296+
nothing
297+
end
289298
if pkg_data !== nothing
290299
f(pkg_data)
291300
end
@@ -406,8 +415,9 @@ Reset a universe back to its pristine state. Removes all previous registrations
406415
and clears the environment of the dev'ed JLLs.
407416
"""
408417
function reset_timeline!(u::Universe)
409-
# Update registries to the latest
410-
u.registry_instances = update_registries!(u.depot_path, u.registries)
418+
# Update registries to the latest, but skip the first one since
419+
# it's our local registry and it errors out if we try to update it.
420+
u.registry_instances[2:end] .= update_registries!(u.registries[2:end], u.depot_path)
411421

412422
# Clear out our local registry and recreate it
413423
rm(joinpath(u.depot_path, "registries", "BB2LocalRegistry"); force=true, recursive=true)

test/UniversesTests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Test, BinaryBuilder2, Pkg, JLLGenerator, Accessors
2-
using BinaryBuilder2: register_jll!, get_package_versions
2+
using BinaryBuilder2: register_jll!, get_package_versions, reset_timeline!
33

44
@testset "Universes" begin
55
# Create a universe holding just `General`
@@ -39,5 +39,9 @@ using BinaryBuilder2: register_jll!, get_package_versions
3939

4040
hwc_versions = get_package_versions(uni, "HelloWorldC2_jll")
4141
@test sort(hwc_versions) == [v"1.3.0", v"1.4.0"]
42+
43+
# Test that `reset_timeline!` eliminates our registrations:
44+
reset_timeline!(uni)
45+
@test isempty(get_package_versions(uni, "HelloWorldC2_jll"))
4246
end
4347
end

0 commit comments

Comments
 (0)