summaryrefslogtreecommitdiff
path: root/test/ruby/test_thread.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-07-25 12:01:09 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-07-25 12:01:09 +0900
commit307835fe314fea6e946a8c9b25bb3912680ed7d1 (patch)
tree3049ea1c7b80f41609d7b19ff03c58f39097fba6 /test/ruby/test_thread.rb
parentb30b727c243ad009a7f8435b559b466418874140 (diff)
Synchronize the test thread sleep
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6176
Diffstat (limited to 'test/ruby/test_thread.rb')
-rw-r--r--test/ruby/test_thread.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index a018f3cdac..afcf1fb463 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -30,16 +30,23 @@ class TestThread < Test::Unit::TestCase
def test_inspect
m = Thread::Mutex.new
+ cv1 = Thread::ConditionVariable.new
+ cv2 = Thread::ConditionVariable.new
m.lock
line = __LINE__+1
th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start do
- m.synchronize {}
+ m.synchronize do
+ cv2.signal
+ cv1.wait(m)
+ end
end
+ cv2.wait(m)
s = th.inspect
assert_include(s, "::C\u{30b9 30ec 30c3 30c9}:")
assert_include(s, " #{__FILE__}:#{line} ")
assert_equal(s, th.to_s)
ensure
+ cv1.signal
m.unlock
th.join
end