From 664eacc7705b8ac4ed2dc58d34396c4da641f75c Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Tue, 31 Dec 2024 00:04:50 -0500 Subject: [PATCH] Test suite: Change `@assert`s to errors, and change bare `using Foo` to `using Foo: name, anothername, ...` --- test/script.jl | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/script.jl b/test/script.jl index 060760a..cea36a6 100644 --- a/test/script.jl +++ b/test/script.jl @@ -1,13 +1,28 @@ #!/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) -@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