Skip to content

Commit 0afeb5e

Browse files
authored
Simplifiy tests infrastructure (#391)
* remove the `runtests` function * remove the `nfail` variable cruft * generate a testset for each included file * do a dummy `@test true` for each test in the loop: if the process errors out the testset would error out as well
1 parent 1e623c4 commit 0afeb5e

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

test/runtests.jl

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,26 @@ end
1414

1515
args = Base.shell_split(get(ENV, "JULIA_MPIEXEC_TEST_ARGS", ""))
1616

17-
function runtests()
18-
nprocs = clamp(Sys.CPU_THREADS, 2, 4)
19-
testdir = dirname(@__FILE__)
20-
istest(f) = endswith(f, ".jl") && startswith(f, "test_")
21-
testfiles = sort(filter(istest, readdir(testdir)))
17+
nprocs = clamp(Sys.CPU_THREADS, 2, 4)
18+
testdir = @__DIR__
19+
istest(f) = endswith(f, ".jl") && startswith(f, "test_")
20+
testfiles = sort(filter(istest, readdir(testdir)))
2221

23-
nfail = 0
24-
printstyled("Running MPI.jl tests\n"; color=:white)
25-
26-
for f in testfiles
27-
mpiexec() do cmd
28-
cmd = `$cmd $args`
29-
if f == "test_spawn.jl"
30-
run(`$cmd -n 1 $(Base.julia_cmd()) $(joinpath(testdir, f))`)
31-
elseif f == "test_threads.jl"
32-
withenv("JULIA_NUM_THREAD" => "4") do
33-
run(`$cmd -n $nprocs $(Base.julia_cmd()) $(joinpath(testdir, f))`)
34-
end
35-
elseif f == "test_error.jl"
36-
r = run(ignorestatus(`$cmd -n $nprocs $(Base.julia_cmd()) $(joinpath(testdir, f))`))
37-
@test !success(r)
38-
else
22+
@testset "$f" for f in testfiles
23+
mpiexec() do cmd
24+
cmd = `$cmd $args`
25+
if f == "test_spawn.jl"
26+
run(`$cmd -n 1 $(Base.julia_cmd()) $(joinpath(testdir, f))`)
27+
elseif f == "test_threads.jl"
28+
withenv("JULIA_NUM_THREAD" => "4") do
3929
run(`$cmd -n $nprocs $(Base.julia_cmd()) $(joinpath(testdir, f))`)
4030
end
31+
elseif f == "test_error.jl"
32+
r = run(ignorestatus(`$cmd -n $nprocs $(Base.julia_cmd()) $(joinpath(testdir, f))`))
33+
@test !success(r)
34+
else
35+
run(`$cmd -n $nprocs $(Base.julia_cmd()) $(joinpath(testdir, f))`)
4136
end
42-
Base.with_output_color(:green,stdout) do io
43-
println(io,"\tSUCCESS: $f")
44-
end
37+
@test true
4538
end
46-
return nfail
4739
end
48-
49-
exit(runtests())

0 commit comments

Comments
 (0)