diff --git a/stdlib/Distributed/src/cluster.jl b/stdlib/Distributed/src/cluster.jl index 0d1614b7e972a5..49df11b6eef0d3 100644 --- a/stdlib/Distributed/src/cluster.jl +++ b/stdlib/Distributed/src/cluster.jl @@ -644,7 +644,7 @@ end Return the cluster cookie. """ -cluster_cookie() = LPROC.cookie +cluster_cookie() = (init_multi(); LPROC.cookie) """ cluster_cookie(cookie) -> cookie @@ -652,6 +652,7 @@ cluster_cookie() = LPROC.cookie Set the passed cookie as the cluster cookie, then returns it. """ function cluster_cookie(cookie) + init_multi() # The cookie must be an ASCII string with length <= HDR_COOKIE_LEN @assert isascii(cookie) @assert length(cookie) <= HDR_COOKIE_LEN diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 04ef09d495a2d9..f17d97697c27e2 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -3,6 +3,8 @@ using Test, Distributed, Random, Serialization, Sockets import Distributed: launch, manage +@test cluster_cookie() isa String + include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl")) @test Distributed.extract_imports(:(begin; import Foo, Bar; let; using Baz; end; end)) ==