Skip to content

Commit

Permalink
Distributed test suite: if Threads.nthreads() > 1, skip certain tes…
Browse files Browse the repository at this point in the history
…ts (#42764)

(cherry picked from commit 0682132)
  • Loading branch information
DilumAluthge authored and KristofferC committed Oct 28, 2021
1 parent 4bf1a0c commit 532b3f8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion stdlib/Distributed/test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,27 @@ function poll_while(f::Function; timeout_seconds::Integer = 120)
return true
end

function _getenv_include_thread_unsafe()
environment_variable_name = "JULIA_TEST_INCLUDE_THREAD_UNSAFE"
default_value = "false"
environment_variable_value = strip(get(ENV, environment_variable_name, default_value))
b = parse(Bool, environment_variable_value)::Bool
return b
end
const _env_include_thread_unsafe = _getenv_include_thread_unsafe()
function include_thread_unsafe()
if Threads.nthreads() > 1
if _env_include_thread_unsafe
return true
end
msg = "Skipping a thread-unsafe test because `Threads.nthreads() > 1`"
@warn msg Threads.nthreads()
Test.@test_broken false
return false
end
return true
end

# Distributed GC tests for Futures
function test_futures_dgc(id)
f = remotecall(myid, id)
Expand Down Expand Up @@ -267,7 +288,9 @@ let wid1 = workers()[1],
fstore = RemoteChannel(wid2)

put!(fstore, rr)
@test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true
if include_thread_unsafe()
@test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true
end
finalize(rr) # finalize locally
yield() # flush gc msgs
@test remotecall_fetch(k -> haskey(Distributed.PGRP.refs, k), wid1, rrid) == true
Expand Down

0 comments on commit 532b3f8

Please sign in to comment.