Skip to content

Commit

Permalink
Fix TestEnv for subpackages: precompile only the new test Project
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Oct 17, 2024
1 parent 3d198c7 commit 569313f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/julia-1.11/activate_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ function activate(pkg::AbstractString=current_pkg_name(); allow_reresolve=true)
@debug "Using _clean_ dep graph"
end

# Now that we have set up the sandbox environment, precompile all its packages:
# (Reconnect the `io` back to the original context so the caller can see the
# precompilation progress.)
Pkg.precompile(temp_ctx; io=ctx.io)

write_env(temp_ctx.env; update_undo=false)

return Base.active_project()
Expand Down
2 changes: 1 addition & 1 deletion src/julia-1.11/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ctx_and_pkgspec(pkg::AbstractString)
pkgspec = deepcopy(PackageSpec(pkg))
ctx = Context()
isinstalled!(ctx, pkgspec) || throw(TestEnvError("$pkg not installed 👻"))
Pkg.instantiate(ctx)
Pkg.instantiate(ctx; allow_autoprecomp = false) # do precomp later within sandbox
return ctx, pkgspec
end

Expand Down
5 changes: 5 additions & 0 deletions src/julia-1.9/activate_set.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ function activate(pkg::AbstractString=current_pkg_name(); allow_reresolve=true)
@debug "Using _clean_ dep graph"
end

# Now that we have set up the sandbox environment, precompile all its packages:
# (Reconnect the `io` back to the original context so the caller can see the
# precompilation progress.)
Pkg.precompile(temp_ctx; io=ctx.io)

write_env(temp_ctx.env; update_undo=false)

return Base.active_project()
Expand Down
3 changes: 2 additions & 1 deletion src/julia-1.9/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ctx_and_pkgspec(pkg::AbstractString)
pkgspec = deepcopy(PackageSpec(pkg))
ctx = Context()
isinstalled!(ctx, pkgspec) || throw(TestEnvError("$pkg not installed 👻"))
Pkg.instantiate(ctx)
Pkg.instantiate(ctx; allow_autoprecomp = false) # do precomp later within sandbox
return ctx, pkgspec
end

Expand Down Expand Up @@ -50,6 +50,7 @@ end

function test_dir_has_project_file(ctx, pkgspec)
test_dir = get_test_dir(ctx, pkgspec)
@show test_dir
test_dir === nothing && return false
return isfile(joinpath(test_dir, "Project.toml"))
end
Expand Down

0 comments on commit 569313f

Please sign in to comment.