@@ -144,6 +144,27 @@ function poll_while(f::Function; timeout_seconds::Integer = 120)
144144 return true
145145end
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
148169function 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