Skip to content

Commit

Permalink
Merge pull request #28 from DilumAluthge-forks/dpa/change-assertions
Browse files Browse the repository at this point in the history
Test suite: Change `@assert`s to errors, and change bare `using Foo` to `using Foo: name, anothername, ...`
  • Loading branch information
kleinhenz authored Jan 16, 2025
2 parents 1aa99a2 + 664eacc commit 2fabc00
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/script.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
#!/usr/bin/env julia

using Distributed, SlurmClusterManager
# We don't use `using Foo` here.
# We either use `using Foo: hello, world`, or we use `import Foo`.
# https://github.com/JuliaLang/julia/pull/42080
using Distributed: addprocs, workers, nworkers, remotecall_fetch
using SlurmClusterManager: SlurmManager

addprocs(SlurmManager())

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

hosts = map(workers()) do id
const hosts = map(workers()) do id
remotecall_fetch(() -> gethostname(), id)
end
sort!(hosts)
println(hosts)

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

0 comments on commit 2fabc00

Please sign in to comment.