Skip to content

Commit 664eacc

Browse files
committed
Test suite: Change @asserts to errors, and change bare using Foo to using Foo: name, anothername, ...
1 parent cf156dd commit 664eacc

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,13 +1,28 @@
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

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

0 commit comments

Comments
 (0)