[前][次][番号順一覧][スレッド一覧]

ruby-changes:51231

From: ngoto <ko1@a...>
Date: Tue, 15 May 2018 23:31:53 +0900 (JST)
Subject: [ruby-changes:51231] ngoto:r63437 (trunk): Split TestThread#test_join_limits into peaces

ngoto	2018-05-15 23:31:47 +0900 (Tue, 15 May 2018)

  New Revision: 63437

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63437

  Log:
    Split TestThread#test_join_limits into peaces
    
    * test/ruby/test_thread.rb (TestThread#test_join_limit_*): Split
      TestThread#test_join_limits for investigating hang-up on Solaris.
      Each method tests only a single limit value.
      [ruby-core:87045] [Bug #14761]

  Modified files:
    trunk/test/ruby/test_thread.rb
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 63436)
+++ test/ruby/test_thread.rb	(revision 63437)
@@ -2,6 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L2
 # frozen_string_literal: false
 require 'test/unit'
 require "rbconfig/sizeof"
+require "timeout"
 
 class TestThread < Test::Unit::TestCase
   class Thread < ::Thread
@@ -228,19 +229,34 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L229
     t3.kill if t3
   end
 
-  def test_join_limits
-    [ RbConfig::LIMITS['FIXNUM_MAX'], RbConfig::LIMITS['UINT64_MAX'],
-      Float::INFINITY ].each do |limit|
+  { 'FIXNUM_MAX' => RbConfig::LIMITS['FIXNUM_MAX'],
+    'UINT64_MAX' => RbConfig::LIMITS['UINT64_MAX'],
+    'INFINITY'   => Float::INFINITY
+  }.each do |name, limit|
+    define_method("test_join_limit_#{name}") do
       t = Thread.new {}
       assert_same t, t.join(limit), "limit=#{limit.inspect}"
     end
-    t = Thread.new { sleep }
-    [ -1, -0.1, RbConfig::LIMITS['FIXNUM_MIN'], RbConfig::LIMITS['INT64_MIN'],
-      -Float::INFINITY
-    ].each do |limit|
-      assert_nil t.join(limit), "limit=#{limit.inspect}"
+  end
+
+  { 'minus_1'        => -1,
+    'minus_0_1'      => -0.1,
+    'FIXNUM_MIN'     => RbConfig::LIMITS['FIXNUM_MIN'],
+    'INT64_MIN'      => RbConfig::LIMITS['INT64_MIN'],
+    'minus_INFINITY' => -Float::INFINITY
+  }.each do |name, limit|
+    define_method("test_join_limit_negative_#{name}") do
+      t = Thread.new { sleep }
+      begin
+        assert_nothing_raised(Timeout::Error) do
+          Timeout.timeout(30) do
+            assert_nil t.join(limit), "limit=#{limit.inspect}"
+          end
+        end
+      ensure
+        t.kill
+      end
     end
-    t.kill
   end
 
   def test_kill_main_thread

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]