Skip to content

Commit

Permalink
respect whether auto-precompilation should happen here
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Dec 15, 2022
1 parent c0b2562 commit 422da4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1888,14 +1888,16 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
sandbox_ctx = Context(;io=ctx.io)
status(sandbox_ctx.env, sandbox_ctx.registries; mode=PKGMODE_COMBINED, io=sandbox_ctx.io, ignore_indent = false, show_usagetips = false)

# Precompile in a child process with the test julia args to ensure native caches match test setup
cmd = gen_test_precompile_code(; coverage, julia_args, test_args)
p, interrupted = subprocess_handler(cmd, ctx, sandbox_ctx, "Precompilation of test environment interrupted. Exiting the test precompilation process")
if !success(p)
if interrupted
return
else
printpkgstyle(ctx.io, :Testing, "Precompilation of test environment failed. Continuing to tests", color = Base.warn_color())
if should_autoprecompile()
# Precompile in a child process with the test julia args to ensure native caches match test setup
cmd = gen_test_precompile_code(; coverage, julia_args, test_args)
p, interrupted = subprocess_handler(cmd, ctx, sandbox_ctx, "Precompilation of test environment interrupted. Exiting the test precompilation process")
if !success(p)
if interrupted
return
else
printpkgstyle(ctx.io, :Testing, "Precompilation of test environment failed. Continuing to tests", color = Base.warn_color())
end
end
end

Expand Down
4 changes: 3 additions & 1 deletion src/Pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,10 @@ end
# Precompilation #
##################

should_autoprecompile() = Base.JLOptions().use_compiled_modules == 1 && get_bool_env("JULIA_PKG_PRECOMPILE_AUTO"; default="true")

function _auto_precompile(ctx::Types.Context, pkgs::Vector{String}=String[]; warn_loaded = true, already_instantiated = false)
if Base.JLOptions().use_compiled_modules == 1 && get_bool_env("JULIA_PKG_PRECOMPILE_AUTO"; default="true")
if should_autoprecompile()
Pkg.precompile(ctx, pkgs; internal_call=true, warn_loaded = warn_loaded, already_instantiated = already_instantiated)
end
end
Expand Down

0 comments on commit 422da4a

Please sign in to comment.