Skip to content

Commit 2fabc00

Browse files
authored
Merge pull request #28 from DilumAluthge-forks/dpa/change-assertions
Test suite: Change `@assert`s to errors, and change bare `using Foo` to `using Foo: name, anothername, ...`
2 parents 1aa99a2 + 664eacc commit 2fabc00

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/script.jl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
#!/usr/bin/env julia
22

3-
using Distributed, SlurmClusterManager
3+
# We don't use `using Foo` here.
4+
# We either use `using Foo: hello, world`, or we use `import Foo`.
5+
# https://github.com/JuliaLang/julia/pull/42080
6+
using Distributed: addprocs, workers, nworkers, remotecall_fetch
7+
using SlurmClusterManager: SlurmManager
8+
49
addprocs(SlurmManager())
510

6-
@assert nworkers() == parse(Int, ENV["SLURM_NTASKS"])
11+
# We intentionally do not use `@assert` here.
12+
# In a future minor release of Julia, `@assert`s may be disabled by default.
13+
const SLURM_NTASKS = parse(Int, ENV["SLURM_NTASKS"])
14+
if nworkers() != SLURM_NTASKS
15+
msg = "Test failed: nworkers=$(nworkers()) does not match SLURM_NTASKS=$(SLURM_NTASKS)"
16+
error(msg)
17+
end
718

8-
hosts = map(workers()) do id
19+
const hosts = map(workers()) do id
920
remotecall_fetch(() -> gethostname(), id)
1021
end
1122
sort!(hosts)
1223
println(hosts)
1324

14-
@assert hosts == ["c1", "c1", "c2", "c2"]
25+
# We don't use `@assert` here, for reason described above.
26+
if hosts != ["c1", "c1", "c2", "c2"]
27+
msg = "Test failed: observed_hosts=$(hosts) does not match expected_hosts=[c1, c1, c2, c2]"
28+
error(msg)
29+
end

0 commit comments

Comments
 (0)