ruby-changes:72425
From: Nobuyoshi <ko1@a...>
Date: Tue, 5 Jul 2022 13:51:58 +0900 (JST)
Subject: [ruby-changes:72425] babdb158d1 (master): Synchronize the test thread not to die before assertions
https://git.ruby-lang.org/ruby.git/commit/?id=babdb158d1 From babdb158d14a626b570db6d42599f1ac2decbed3 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 5 Jul 2022 13:50:45 +0900 Subject: Synchronize the test thread not to die before assertions --- test/ruby/test_thread.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L29 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/