Skip to content

Commit

Permalink
add Pkg to test env as a dep rather than via LOAD_PATH (JuliaLang#3676)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Oct 26, 2023
1 parent 487f9e2 commit 75960e5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,7 @@ function gen_test_code(source_path::String; coverage, julia_args::Cmd, test_args
end

function gen_test_precompile_code(source_path::String; coverage, julia_args::Cmd, test_args::Cmd)
pkgdir = joinpath(@__DIR__, "..")
code = """
pushfirst!(LOAD_PATH, $(repr(pkgdir)))
try using Pkg
catch
@warn "Pkg failed to load, skipping precompilation."
Expand Down Expand Up @@ -1755,12 +1753,22 @@ function sandbox(fn::Function, ctx::Context, target::PackageSpec, target_path::S
tmp_preferences = joinpath(tmp, first(Base.preferences_names))

# Copy env info over to temp env
if sandbox_project_override !== nothing
Types.write_project(sandbox_project_override, tmp_project)
elseif isfile(sandbox_project)
cp(sandbox_project, tmp_project)
chmod(tmp_project, 0o600)
if sandbox_project_override === nothing
if isfile(sandbox_project)
sandbox_project_override = read_project(sandbox_project)
else
sandbox_project_override = Project()
end
end
# add Pkg so that the test environment sandbox subprocesses can be precompiled
Pkg_uuid = UUID(PkgUUID)
if get!(sandbox_project_override.deps, "Pkg", Pkg_uuid) != Pkg_uuid
@warn """
A package called Pkg is declared as a dependency with a UUID that doesn't match the Pkg stdlib.
This may cause unexpected behavior"""
end
Types.write_project(sandbox_project_override, tmp_project)

# create merged manifest
# - copy over active subgraph
# - abspath! to maintain location of all deved nodes
Expand Down

0 comments on commit 75960e5

Please sign in to comment.