Skip to content

Commit

Permalink
Test fixes (#3972)
Browse files Browse the repository at this point in the history
* fix test that modifies wrong depot registry

* fix artifact test with correct Pkg

* ensure shared depots are modified during isolated tests

* update setup-julia
  • Loading branch information
IanButterworth authored Jul 25, 2024
1 parent 34bb51e commit 2fdfaba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
echo "TMP=${USERPROFILE}\AppData\Local\Temp" >> ${GITHUB_ENV}
echo "TEMP=${USERPROFILE}\AppData\Local\Temp" >> ${GITHUB_ENV}
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
Expand All @@ -90,7 +90,7 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
# version: '1.6'
version: 'nightly'
Expand Down
1 change: 1 addition & 0 deletions test/artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ end
# Verify that the name-based override worked; extract paths from module that
# loads overridden package artifacts.
Pkg.activate(depot_container) do
add_this_pkg()
# TODO: This causes a loading.jl warning, probably Pkg is clashing because of a different UUID??
(arty_path, barty_path) = Core.eval(Module(:__anon__), quote
using ArtifactOverrideLoading
Expand Down
19 changes: 13 additions & 6 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,21 @@ function isolate(fn::Function; loaded_depot=false, linked_reg=true)
withenv("JULIA_PROJECT" => nothing,
"JULIA_LOAD_PATH" => nothing,
"JULIA_PKG_DEVDIR" => nothing) do
target_depot = nothing
target_depot = realpath(mktempdir())
push!(LOAD_PATH, "@", "@v#.#", "@stdlib")
push!(DEPOT_PATH, target_depot)
loaded_depot && push!(DEPOT_PATH, LOADED_DEPOT)
depot_mtimes = Dict(d => mtime(d) for d in DEPOT_PATH if isdir(d))
try
target_depot = realpath(mktempdir())
push!(LOAD_PATH, "@", "@v#.#", "@stdlib")
push!(DEPOT_PATH, target_depot)
loaded_depot && push!(DEPOT_PATH, LOADED_DEPOT)
fn()
finally
for (d, t) in depot_mtimes
d == target_depot && continue # tests allowed to modify target depot
isdir(d) || continue
if mtime(d) != t
error("shared depot $d was modified during isolated test: readdir(depot) = $(readdir(d))")
end
end
if !haskey(ENV, "CI") && target_depot !== nothing && isdir(target_depot)
try
Base.rm(target_depot; force=true, recursive=true)
Expand All @@ -107,7 +114,7 @@ end

function isolate_and_pin_registry(fn::Function; registry_url::String, registry_commit::String)
isolate(loaded_depot = false, linked_reg = true) do
this_gen_reg_path = joinpath(last(Base.DEPOT_PATH), "registries", "General")
this_gen_reg_path = joinpath(first(Base.DEPOT_PATH), "registries", "General")
rm(this_gen_reg_path; force = true) # delete the symlinked registry directory
cmd = `git clone $(registry_url) $(this_gen_reg_path)`
run(pipeline(cmd, stdout = stdout_f(), stderr = stderr_f()))
Expand Down

0 comments on commit 2fdfaba

Please sign in to comment.