From 614b8d616068ed6bd67566aec7be2ebf65da3a4b Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 24 Oct 2016 03:46:51 +0000 Subject: test_thread.rb: count accurately * test/ruby/test_thread.rb (test_thread_timer_and_interrupt): count only signal handling time accurately without setup and cleanup time. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_thread.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 9cb6a43cd5..5f756f93bf 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -836,24 +836,24 @@ _eom def test_thread_timer_and_interrupt bug5757 = '[ruby-dev:44985]' - t0 = Time.now.to_f pid = nil cmd = 'Signal.trap(:INT, "DEFAULT"); r,=IO.pipe; Thread.start {Thread.pass until Thread.main.stop?; puts; STDOUT.flush}; r.read' opt = {} opt[:new_pgroup] = true if /mswin|mingw/ =~ RUBY_PLATFORM - s, _err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true, opt) do |in_p, out_p, err_p, cpid| + s, t, _err = EnvUtil.invoke_ruby(['-e', cmd], "", true, true, opt) do |in_p, out_p, err_p, cpid| out_p.gets pid = cpid + t0 = Time.now.to_f Process.kill(:SIGINT, pid) Process.wait(pid) - [$?, err_p.read] + t1 = Time.now.to_f + [$?, t1 - t0, err_p.read] end - t1 = Time.now.to_f assert_equal(pid, s.pid, bug5757) assert_equal([false, true, false, Signal.list["INT"]], [s.exited?, s.signaled?, s.stopped?, s.termsig], "[s.exited?, s.signaled?, s.stopped?, s.termsig]") - assert_in_delta(t1 - t0, 1, 1, bug5757) + assert_include(0..2, t, bug5757) end def test_thread_join_in_trap -- cgit v1.2.3