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

ruby-changes:46368

From: ko1 <ko1@a...>
Date: Wed, 26 Apr 2017 02:50:39 +0900 (JST)
Subject: [ruby-changes:46368] ko1:r58482 (trunk): add timeout.

ko1	2017-04-26 02:50:34 +0900 (Wed, 26 Apr 2017)

  New Revision: 58482

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

  Log:
    add timeout.
    
    * test/ruby/test_trace.rb (test_trace_stackoverflow): sometimes this test
      was stopped forever and killed by test process forcibly. However, this
      test only checks if this code cause some critical failure such as SEGV.
      So that we can add timeout for this code.

  Modified files:
    trunk/test/ruby/test_trace.rb
Index: test/ruby/test_trace.rb
===================================================================
--- test/ruby/test_trace.rb	(revision 58481)
+++ test/ruby/test_trace.rb	(revision 58482)
@@ -63,6 +63,7 @@ class TestTrace < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_trace.rb#L63
   def test_trace_stackoverflow
     assert_normal_exit("#{<<-"begin;"}\n#{<<~"end;"}", timeout: 60)
     begin;
+      require 'timeout'
       require 'tracer'
       class HogeError < StandardError
         def to_s
@@ -70,8 +71,16 @@ class TestTrace < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_trace.rb#L71
         end
       end
       Tracer.stdout = open(IO::NULL, "w")
-      Tracer.on
-      HogeError.new.to_s
+      begin
+        Timeout.timeout(5) do
+          Tracer.on
+          HogeError.new.to_s
+        end
+      rescue Timeout::Error
+        # ok. there are no SEGV or critical error
+      rescue SystemStackError => e
+        # ok.
+      end
     end;
   end
 end

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

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