Skip to content

Commit

Permalink
Ensure precompilation when testing runs without threads on Julia 1.11
Browse files Browse the repository at this point in the history
Precompilation with threads is not supported: JuliaLang/julia#53572 (comment)
  • Loading branch information
stemann committed Jan 25, 2025
1 parent 2eb8ae5 commit 20ab98e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2060,18 +2060,20 @@ function test(ctx::Context, pkgs::Vector{PackageSpec};
test_fn !== nothing && test_fn()
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)
flags = gen_subprocess_flags(source_path; coverage,julia_args)
precompile_julia_args = Cmd(filter(!startswith("--threads"), julia_args.exec)) # precompilation with threads is not supported
precompile_flags = gen_subprocess_flags(source_path; coverage, julia_args = precompile_julia_args)

if should_autoprecompile()
cacheflags = Base.CacheFlags(parse(UInt8, read(`$(Base.julia_cmd()) $(flags) --eval 'show(ccall(:jl_cache_flags, UInt8, ()))'`, String)))
cacheflags = Base.CacheFlags(parse(UInt8, read(`$(Base.julia_cmd()) $(precompile_flags) --eval 'show(ccall(:jl_cache_flags, UInt8, ()))'`, String)))
Pkg.activate(sandbox_ctx.env.project_file; #=io=devnull=#) do
Pkg.precompile(sandbox_ctx; io=sandbox_ctx.io, configs = flags => cacheflags)
Pkg.precompile(sandbox_ctx; io=sandbox_ctx.io, configs = precompile_flags => cacheflags)
end
end

printpkgstyle(ctx.io, :Testing, "Running tests...")
flush(ctx.io)
code = gen_test_code(source_path; test_args)
flags = gen_subprocess_flags(source_path; coverage, julia_args = julia_args)
cmd = `$(Base.julia_cmd()) $(flags) --threads=$(get_threads_spec()) --eval $code`
p, interrupted = subprocess_handler(cmd, ctx, sandbox_ctx, "Tests interrupted. Exiting the test process")
if success(p)
Expand Down

0 comments on commit 20ab98e

Please sign in to comment.