diff --git a/test/test_thread_pool.rb b/test/test_thread_pool.rb index ed51e191..18901d6a 100644 --- a/test/test_thread_pool.rb +++ b/test/test_thread_pool.rb @@ -223,27 +223,32 @@ class TestThreadPool < Minitest::Test def test_auto_reap_dead_threads pool = new_pool(2,2) { Thread.current.kill } + pool.auto_reap! 0.1 + + pause + assert_equal 2, pool.spawned - # TODO: is there a point to these two lines? pool << 1 pool << 2 - pool.auto_reap! 0.1 - pause assert_equal 0, pool.spawned end def test_force_shutdown_immediately + finish = false + rescued = false + pool = new_pool(0, 1) do |work| begin @work_mutex.synchronize do @work_done.signal end - sleep 10 # TODO: do something here other than sleep + Thread.pass until finish rescue Puma::ThreadPool::ForceShutdown + rescued = true end end @@ -252,7 +257,9 @@ class TestThreadPool < Minitest::Test @work_mutex.synchronize do @work_done.wait(@work_mutex, 5) pool.shutdown(0) + finish = true assert_equal 0, pool.spawned + assert rescued end end end