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

ruby-changes:33006

From: naruse <ko1@a...>
Date: Sat, 22 Feb 2014 00:12:56 +0900 (JST)
Subject: [ruby-changes:33006] naruse:r45085 (ruby_2_1): merge revision(s) 44616, 44622, 44623, 44626, 44632, 44636:

naruse	2014-02-22 00:12:52 +0900 (Sat, 22 Feb 2014)

  New Revision: 45085

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45085

  Log:
    merge revision(s) 44616,44622,44623,44626,44632,44636:
    
    add timeout to test_do_reply
    
    http://fb64b.rubyci.org/~chkbuild/ruby-trunk/log/20140115T073301Z.log.html.gz

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/test/rinda/test_rinda.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 45084)
+++ ruby_2_1/version.h	(revision 45085)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.1"
-#define RUBY_RELEASE_DATE "2014-02-21"
-#define RUBY_PATCHLEVEL 47
+#define RUBY_RELEASE_DATE "2014-02-22"
+#define RUBY_PATCHLEVEL 48
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 21
+#define RUBY_RELEASE_DAY 22
 
 #include "ruby/version.h"
 
Index: ruby_2_1/test/rinda/test_rinda.rb
===================================================================
--- ruby_2_1/test/rinda/test_rinda.rb	(revision 45084)
+++ ruby_2_1/test/rinda/test_rinda.rb	(revision 45085)
@@ -4,7 +4,7 @@ require 'drb/drb' https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/rinda/test_rinda.rb#L4
 require 'drb/eq'
 require 'rinda/ring'
 require 'rinda/tuplespace'
-
+require 'timeout'
 require 'singleton'
 
 module Rinda
@@ -559,6 +559,10 @@ class TestRingServer < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/rinda/test_rinda.rb#L559
   end
 
   def test_do_reply
+    with_timeout(10) {_test_do_reply}
+  end
+
+  def _test_do_reply
     called = nil
 
     callback = proc { |ts|
@@ -571,12 +575,16 @@ class TestRingServer < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/rinda/test_rinda.rb#L575
 
     @rs.do_reply
 
-    Thread.pass until called
+    wait_for(10) {called}
 
     assert_same @ts, called
   end
 
   def test_do_reply_local
+    with_timeout(10) {_test_do_reply_local}
+  end
+
+  def _test_do_reply_local
     called = nil
 
     callback = proc { |ts|
@@ -587,7 +595,7 @@ class TestRingServer < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/rinda/test_rinda.rb#L595
 
     @rs.do_reply
 
-    Thread.pass until called
+    wait_for(10) {called}
 
     assert_same @ts, called
   end
@@ -674,6 +682,46 @@ class TestRingServer < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/rinda/test_rinda.rb#L682
     assert_nil(@rs.do_reply, 'otherwise should hang forever')
   end
 
+  private
+
+  def with_timeout(n)
+    aoe = Thread.abort_on_exception
+    Thread.abort_on_exception = true
+    tl0 = Thread.list
+    tl = nil
+    th = Thread.new(Thread.current) do |mth|
+      sleep n
+      (tl = Thread.list - tl0).each {|t|t.raise(Timeout::Error)}
+      mth.raise(Timeout::Error)
+    end
+    tl0 << th
+  rescue Timeout::Error => e
+    if tl
+      bt = e.backtrace
+      tl.each do |t|
+        begin
+          t.value
+        rescue Timeout::Error => e
+          bt.unshift("")
+          bt[0, 0] = e.backtrace
+        end
+      end
+    end
+    raise Timeout::Error, "timeout", bt
+  ensure
+    th.kill if th
+    Thread.abort_on_exception = aoe
+  end
+
+  def wait_for(n)
+    t = n + Process.clock_gettime(Process::CLOCK_MONOTONIC, :second)
+    until yield
+      if t < Process.clock_gettime(Process::CLOCK_MONOTONIC, :second)
+        flunk "timeout during waiting call"
+      end
+      sleep 0.1
+    end
+  end
 end
 
 class TestRingFinger < Test::Unit::TestCase

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r44616,44622-44623,44626,44632,44636


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

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