Skip to content

Commit

Permalink
[mpiexecjl] Accept JULIA_BINDIR as environment variable (#481)
Browse files Browse the repository at this point in the history
[`JULIA_BINDIR`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_BINDIR)
is a standard Julia environment variable pointing to the directory where the
`julia` binary is present.
  • Loading branch information
giordano authored Jul 5, 2021
1 parent c5c6bf2 commit 68545ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions bin/mpiexecjl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ SCRIPT='
using MPI
ENV["JULIA_PROJECT"] = dirname(Base.active_project())
mpiexec(exe -> run(`$exe $ARGS`))'
if [ -n "${JULIA_BINDIR}" ]; then
JULIA_CMD="${JULIA_BINDIR}/julia"
else
JULIA_CMD="julia"
fi

if [ -n "${PROJECT_ARG}" ]; then
julia "${PROJECT_ARG}" --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
"${JULIA_CMD}" "${PROJECT_ARG}" --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
else
julia --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
"${JULIA_CMD}" --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
fi
13 changes: 9 additions & 4 deletions test/mpiexecjl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ using MPI
mpiexecjl = joinpath(dir, "mpiexecjl")
julia = joinpath(Sys.BINDIR, Base.julia_exename())
example = joinpath(@__DIR__, "..", "docs", "examples", "01-hello.jl")
p = run(`$(mpiexecjl) --project=$(dir) $(julia) --startup-file=no -q $(example)`)
env = ["JULIA_BINDIR" => Sys.BINDIR]
p = withenv(env...) do
run(`$(mpiexecjl) --project=$(dir) $(julia) --startup-file=no -q $(example)`)
end
@test success(p)
# Test help messages
for help_flag in ("-h", "--help")
help_message = read(`$(mpiexecjl) --project=$(dir) --help`, String)
help_message = withenv(env...) do
read(`$(mpiexecjl) --project=$(dir) --help`, String)
end
@test occursin(r"Usage:.*MPIEXEC_ARGUMENTS", help_message)
end
# Without arguments, or only with the `--project` option, the wrapper will fail
@test !success(`$(mpiexecjl) --project=$(dir)`)
@test !success(`$(mpiexecjl)`)
@test !withenv(() -> success(`$(mpiexecjl) --project=$(dir)`), env...)
@test !withenv(() -> success(`$(mpiexecjl)`), env...)
end
end

0 comments on commit 68545ed

Please sign in to comment.