Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributed test suite: if Threads.nthreads() > 1, skip certain tests #42764

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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