Skip to content

Commit 8c5a426

Browse files
authored
Merge pull request #34 from DilumAluthge-forks/dpa/testset
Put the entire test suite inside a top-level `@testset`
2 parents f668821 + a78b063 commit 8c5a426

File tree

1 file changed

+40
-37
lines changed

1 file changed

+40
-37
lines changed

test/runtests.jl

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,44 @@ else
1515
ENV["JULIA_DEBUG"] = original_JULIA_DEBUG * ",SlurmClusterManager"
1616
end
1717

18-
# test that slurm is available
19-
@test !(Sys.which("sinfo") === nothing)
20-
21-
# submit job
22-
# project should point to top level dir so that SlurmClusterManager is available to script.jl
23-
project_path = abspath(joinpath(@__DIR__, ".."))
24-
println("project_path = $project_path")
25-
jobid = withenv("JULIA_PROJECT"=>project_path) do
26-
strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.jl`, String))
27-
end
28-
println("jobid = $jobid")
29-
30-
# get job state from jobid
31-
getjobstate = jobid -> begin
32-
cmd = Cmd(`scontrol show jobid=$jobid`, ignorestatus=true)
33-
info = read(cmd, String)
34-
state = match(r"JobState=(\S*)", info)
35-
return state === nothing ? nothing : state.captures[1]
36-
end
37-
38-
# wait for job to complete
39-
status = timedwait(60.0, pollint=1.0) do
18+
@testset "SlurmClusterManager.jl" begin
19+
# test that slurm is available
20+
@test !(Sys.which("sinfo") === nothing)
21+
22+
# submit job
23+
# project should point to top level dir so that SlurmClusterManager is available to script.jl
24+
project_path = abspath(joinpath(@__DIR__, ".."))
25+
println("project_path = $project_path")
26+
jobid = withenv("JULIA_PROJECT"=>project_path) do
27+
strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.jl`, String))
28+
end
29+
println("jobid = $jobid")
30+
31+
# get job state from jobid
32+
getjobstate = jobid -> begin
33+
cmd = Cmd(`scontrol show jobid=$jobid`, ignorestatus=true)
34+
info = read(cmd, String)
35+
state = match(r"JobState=(\S*)", info)
36+
return state === nothing ? nothing : state.captures[1]
37+
end
38+
39+
# wait for job to complete
40+
status = timedwait(60.0, pollint=1.0) do
41+
state = getjobstate(jobid)
42+
state == nothing && return false
43+
println("jobstate = $state")
44+
return state == "COMPLETED" || state == "FAILED"
45+
end
46+
4047
state = getjobstate(jobid)
41-
state == nothing && return false
42-
println("jobstate = $state")
43-
return state == "COMPLETED" || state == "FAILED"
44-
end
45-
46-
state = getjobstate(jobid)
47-
48-
# check that job finished running within timelimit (either completed or failed)
49-
@test status == :ok
50-
@test state == "COMPLETED"
51-
52-
# print job output
53-
output = read("test.out", String)
54-
println("script output:")
55-
println(output)
48+
49+
# check that job finished running within timelimit (either completed or failed)
50+
@test status == :ok
51+
@test state == "COMPLETED"
52+
53+
# print job output
54+
output = read("test.out", String)
55+
println("script output:")
56+
println(output)
57+
58+
end # testset "SlurmClusterManager.jl"

0 commit comments

Comments
 (0)