From 268269687c8747eb0bb67b09025b7ff7f495eba6 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 13 Jul 2022 13:13:33 +0200 Subject: [PATCH] thread/test_instrumentation_api: cleanup all existing threads in setup We saw the following failure: ``` TestThreadInstrumentation#test_thread_instrumentation [/tmp/ruby/v3/src/trunk-random3/test/-ext-/thread/test_instrumentation_api.rb:25]: Expected 0..3 to include 4. ``` Which shouldn't happen unless somehow there was a leaked thread. --- test/-ext-/thread/test_instrumentation_api.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/-ext-/thread/test_instrumentation_api.rb b/test/-ext-/thread/test_instrumentation_api.rb index b8f21fa92a..a187a3c13f 100644 --- a/test/-ext-/thread/test_instrumentation_api.rb +++ b/test/-ext-/thread/test_instrumentation_api.rb @@ -6,6 +6,15 @@ class TestThreadInstrumentation < Test::Unit::TestCase pend("No windows support") if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM require '-test-/thread/instrumentation' + + Thread.list.each do |thread| + if thread != Thread.current + thread.kill + thread.join rescue nil + end + end + assert_equal [Thread.current], Thread.list + Bug::ThreadInstrumentation.reset_counters Bug::ThreadInstrumentation::register_callback end