Module: Maxitest::Threads
- Included in:
- Minitest::Test
- Defined in:
- lib/maxitest/threads.rb
Instance Method Summary collapse
-
#maxitest_extra_threads ⇒ Object
if setup crashes we do not return anything to make the initial error visible.
-
#maxitest_kill_extra_threads ⇒ Object
also a helper methods for users.
-
#maxitest_wait_for_extra_threads ⇒ Object
also a helper methods for users.
- #setup ⇒ Object
- #teardown ⇒ Object
Instance Method Details
#maxitest_extra_threads ⇒ Object
if setup crashes we do not return anything to make the initial error visible
30 31 32 |
# File 'lib/maxitest/threads.rb', line 30 def maxitest_extra_threads @maxitest_threads_before ? Thread.list - @maxitest_threads_before : [] end |
#maxitest_kill_extra_threads ⇒ Object
also a helper methods for users
25 26 27 |
# File 'lib/maxitest/threads.rb', line 25 def maxitest_kill_extra_threads maxitest_extra_threads.map(&:kill).map(&:join) end |
#maxitest_wait_for_extra_threads ⇒ Object
also a helper methods for users
20 21 22 |
# File 'lib/maxitest/threads.rb', line 20 def maxitest_wait_for_extra_threads sleep 0.01 while maxitest_extra_threads.any? end |
#setup ⇒ Object
6 7 8 9 |
# File 'lib/maxitest/threads.rb', line 6 def setup @maxitest_threads_before = Thread.list super end |
#teardown ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/maxitest/threads.rb', line 11 def teardown super found = maxitest_extra_threads raise "Test left #{found.size} extra threads (#{found})" if found.any? ensure maxitest_kill_extra_threads end |