summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2022-07-05 13:50:45 +0900
committerNobuyoshi Nakada <[email protected]>2022-07-05 13:50:45 +0900
commitbabdb158d14a626b570db6d42599f1ac2decbed3 (patch)
treeeae382a52b50ece3f2f7f68af7b9133ea0dfa5d6
parent3a9ff9457a5cee72ff5b8dff844f4453fc284bed (diff)
Synchronize the test thread not to die before assertions
-rw-r--r--test/ruby/test_thread.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index ba2c5b8e7c..cdb7309fb7 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -29,13 +29,18 @@ class TestThread < Test::Unit::TestCase
end
def test_inspect
+ m = Thread::Mutex.new
+ m.lock
line = __LINE__+1
- th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start{}
+ th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start do
+ m.synchronize {}
+ end
s = th.inspect
assert_include(s, "::C\u{30b9 30ec 30c3 30c9}:")
assert_include(s, " #{__FILE__}:#{line} ")
assert_equal(s, th.to_s)
ensure
+ m.unlock
th.join
end