Skip to content

Commit 2ecd682

Browse files
giordanovchuravy
andcommitted
Use function instead of variable for the command to run in tests
Co-authored-by: Valentin Churavy <[email protected]>
1 parent 40e7cf7 commit 2ecd682

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/runtests.jl

+6-8
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,22 @@ testfiles = sort(filter(istest, readdir(testdir)))
3737

3838
@testset "$f" for f in testfiles
3939
mpiexec() do mpirun
40-
cmd = `$mpirun -n $nprocs $(Base.julia_cmd()) $(joinpath(testdir, f))`
40+
cmd(n=nprocs) = `$mpirun -n $n $(Base.julia_cmd()) $(joinpath(testdir, f))`
4141
if f == "test_spawn.jl"
4242
# Some command as the others, but always use a single process
43-
_cmd = deepcopy(cmd)
44-
_cmd.exec[findfirst(==("$nprocs"), _cmd.exec)] = "1"
45-
run(_cmd)
43+
run(cmd(1))
4644
elseif f == "test_threads.jl"
4745
withenv("JULIA_NUM_THREADS" => "4") do
48-
run(cmd)
46+
run(cmd())
4947
end
5048
elseif f == "test_error.jl"
51-
r = run(ignorestatus(cmd))
49+
r = run(ignorestatus(cmd()))
5250
@test !success(r)
5351
elseif f == "test_errorhandler.jl" && (MPI.identify_implementation()[1] == MPI.UnknownMPI ||
5452
# Fujitsu MPI is known to not work with custom error handlers
5553
startswith(MPI.MPI_LIBRARY_VERSION_STRING, "FUJITSU MPI"))
5654
try
57-
run(cmd)
55+
run(cmd())
5856
catch e
5957
@error """
6058
$(f) tests failed. This may due to the fact this implementation of MPI doesn't support custom error handlers.
@@ -69,7 +67,7 @@ testfiles = sort(filter(istest, readdir(testdir)))
6967
if get(ENV, "JULIA_MPI_TEST_DISABLE_REDUCE_ON_APPLE", "") != "" && Sys.isapple() && f == "test_reduce.jl"
7068
return
7169
end
72-
run(cmd)
70+
run(cmd())
7371
end
7472
@test true
7573
end

0 commit comments

Comments
 (0)