Skip to content

Commit cd6a6b4

Browse files
authored
Consistently use Base.julia_cmd() in tests (#706)
This ensures we use same flags as parent Julia process and avoid invalidating the cache, which would then lead to multiple julia processes recompiling the cache at the same time and causing race conditions.
1 parent 1a0bee6 commit cd6a6b4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

test/mpiexecjl.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ using MPI
77
# `mpiexecjl`
88
Pkg.activate(dir; io=devnull)
99
Pkg.develop(PackageSpec(path=joinpath(@__DIR__, "..")); io=devnull)
10+
# Precompile in advance to avoid race conditions when running multiple Julia
11+
# processes in parallel.
12+
Pkg.precompile(; io=devnull)
1013
# Test installation
1114
@test_logs (:info, r"Installing") (:info, r"Done") MPI.install_mpiexecjl(; destdir = dir)
1215
# Test a run of mpiexec
1316
nprocs_str = get(ENV, "JULIA_MPI_TEST_NPROCS", "")
1417
nprocs = nprocs_str == "" ? clamp(Sys.CPU_THREADS, 2, 4) : parse(Int, nprocs_str)
1518
mpiexecjl = joinpath(dir, "mpiexecjl")
16-
julia = joinpath(Sys.BINDIR, Base.julia_exename())
19+
# `Base.julia_cmd()` ensures keeping consistent flags when running subprocesses.
20+
julia = Base.julia_cmd()
1721
example = joinpath(@__DIR__, "..", "docs", "examples", "01-hello.jl")
1822
env = ["JULIA_BINDIR" => Sys.BINDIR]
1923
p = withenv(env...) do

test/test_spawn.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const N = clamp(Sys.CPU_THREADS, 2, 4)
88
exename = joinpath(Sys.BINDIR, Base.julia_exename())
99
@test isfile(exename)
1010
errors = Vector{Cint}(undef, N-1)
11-
intercomm = MPI.Comm_spawn(exename, [joinpath(@__DIR__, "spawned_worker.jl")], N-1, MPI.COMM_WORLD, errors)
11+
# Ensure using consistent flags when spawning subprocesses by using same arguments as `Base.julia_cmd`.
12+
intercomm = MPI.Comm_spawn(exename, vcat(Base.julia_cmd()[2:end], joinpath(@__DIR__, "spawned_worker.jl")), N-1, MPI.COMM_WORLD, errors)
1213
@test errors == zeros(Cint,N-1)
1314
world_comm = MPI.Intercomm_merge(intercomm, false)
1415

0 commit comments

Comments
 (0)