Skip to content

Commit

Permalink
Distributed test suite: if Threads.nthreads() > 1, skip certain tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge committed Oct 25, 2021
1 parent 0ddba15 commit e93654d
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()
default_value = "false"
environment_variable_name = "JULIA_TEST_INCLUDE_THREAD_UNSAFE"
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 e93654d

Please sign in to comment.