From 301d669a3150762c51473fde9c486169241e2ec0 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 25 Apr 2017 17:50:34 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_trace.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_trace.rb b/test/ruby/test_trace.rb index d7a683b083..434da70107 100644 --- a/test/ruby/test_trace.rb +++ b/test/ruby/test_trace.rb @@ -63,6 +63,7 @@ class TestTrace < Test::Unit::TestCase 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 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 -- cgit v1.2.3