Skip to content

Commit e1771e4

Browse files
DilumAluthgeKristofferC
authored andcommitted
Distributed test suite: if Threads.nthreads() > 1, skip certain tests (JuliaLang/julia#42764)
(cherry picked from commit 2cfdbec)
1 parent 9fda024 commit e1771e4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

test/distributed_exec.jl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@ function poll_while(f::Function; timeout_seconds::Integer = 120)
144144
return true
145145
end
146146

147+
function _getenv_include_thread_unsafe()
148+
environment_variable_name = "JULIA_TEST_INCLUDE_THREAD_UNSAFE"
149+
default_value = "false"
150+
environment_variable_value = strip(get(ENV, environment_variable_name, default_value))
151+
b = parse(Bool, environment_variable_value)::Bool
152+
return b
153+
end
154+
const _env_include_thread_unsafe = _getenv_include_thread_unsafe()
155+
function include_thread_unsafe()
156+
if Threads.nthreads() > 1
157+
if _env_include_thread_unsafe
158+
return true
159+
end
160+
msg = "Skipping a thread-unsafe test because `Threads.nthreads() > 1`"
161+
@warn msg Threads.nthreads()
162+
Test.@test_broken false
163+
return false
164+
end
165+
return true
166+
end
167+
147168
# Distributed GC tests for Futures
148169
function test_futures_dgc(id)
149170
f = remotecall(myid, id)
@@ -267,7 +288,9 @@ let wid1 = workers()[1],
267288
fstore = RemoteChannel(wid2)
268289

269290
put!(fstore, rr)
270-
@test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true
291+
if include_thread_unsafe()
292+
@test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true
293+
end
271294
finalize(rr) # finalize locally
272295
yield() # flush gc msgs
273296
@test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true

0 commit comments

Comments
 (0)