Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set JULIA_BINDIR when running mpiexecjl tests #858

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions test/mpiexecjl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@ using MPI
# Test a run of mpiexec
nprocs_str = get(ENV, "JULIA_MPI_TEST_NPROCS", "")
nprocs = nprocs_str == "" ? clamp(Sys.CPU_THREADS, 2, 4) : parse(Int, nprocs_str)
mpiexecjl = joinpath(dir, "mpiexecjl")
env = ["JULIA_BINDIR" => Sys.BINDIR]
mpiexecjl = addenv(`$(joinpath(dir, "mpiexecjl"))`, env...)
Comment on lines -18 to +19
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure about why JULIA_BINDIR is needed, but I think that ensuring mpiexecjl is consistently called with the same environment in all these tests is a good change: it's less error-prone as it avoids missing something in possible future tests. As a side effect, we can slightly simplify the code in these tests whenever we call mpiexecjl.

# `Base.julia_cmd()` ensures keeping consistent flags when running subprocesses.
julia = Base.julia_cmd()
example = joinpath(@__DIR__, "..", "docs", "examples", "01-hello.jl")
env = ["JULIA_BINDIR" => Sys.BINDIR]
p = withenv(env...) do
run(`$(mpiexecjl) -n $(nprocs) --project=$(dir) $(julia) --startup-file=no -q $(example)`)
end
p = run(`$(mpiexecjl) -n $(nprocs) --project=$(dir) $(julia) --startup-file=no -q $(example)`)
@test success(p)
# Test help messages
for help_flag in ("-h", "--help")
help_message = withenv(env...) do
read(`$(mpiexecjl) --project=$(dir) --help`, String)
end
help_message = read(`$(mpiexecjl) --project=$(dir) --help`, String)
@test occursin(r"Usage:.*MPIEXEC_ARGUMENTS", help_message)
end
# Without arguments, or only with the `--project` option, the wrapper will fail
@test !withenv(() -> success(`$(mpiexecjl) --project=$(dir)`), env...)
@test !withenv(() -> success(`$(mpiexecjl)`), env...)
@test !success(`$(mpiexecjl) --project=$(dir)`)
@test !success(mpiexecjl)
# Test that the wrapper exits with the same exit code as the MPI process
exit_code = 10
p = run(`$(mpiexecjl) -n $(nprocs) --project=$(dir) $(julia) --startup-file=no -e "exit($(exit_code))"`; wait=false)
Expand Down
Loading