mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/rake: avoid leaking threads
* test/rake/test_rake_multi_task.rb (teardown): clean up thread pool to avoid leaking threads. * test/rake/test_rake_task_with_arguments.rb (teardown): ditto. * test/rake/test_rake_thread_pool.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ea9e8fedb3
commit
15da4792de
3 changed files with 11 additions and 0 deletions
|
@ -13,6 +13,12 @@ class TestRakeMultiTask < Rake::TestCase
|
|||
@mutex = Mutex.new
|
||||
end
|
||||
|
||||
def teardown
|
||||
Rake.application.thread_pool.join
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def add_run(obj)
|
||||
@mutex.synchronize do
|
||||
@runs << obj
|
||||
|
|
|
@ -12,6 +12,7 @@ class TestRakeTaskWithArguments < Rake::TestCase
|
|||
|
||||
def teardown
|
||||
Rake::TaskManager.record_task_metadata = false
|
||||
Rake.application.thread_pool.join
|
||||
|
||||
super
|
||||
end
|
||||
|
|
|
@ -33,6 +33,8 @@ class TestRakeTestThreadPool < Rake::TestCase
|
|||
refute_equal threads[0], threads[1]
|
||||
refute_equal Thread.current, threads[0]
|
||||
refute_equal Thread.current, threads[1]
|
||||
ensure
|
||||
pool.join
|
||||
end
|
||||
|
||||
def test_pool_creates_the_correct_number_of_threads
|
||||
|
@ -95,6 +97,8 @@ class TestRakeTestThreadPool < Rake::TestCase
|
|||
assert_raises(CustomError) do
|
||||
pool.future(2, &deep_exception_block).value
|
||||
end
|
||||
ensure
|
||||
pool.join
|
||||
end
|
||||
|
||||
def test_pool_prevents_deadlock
|
||||
|
|
Loading…
Reference in a new issue