ruby-changes:44412
From: nobu <ko1@a...>
Date: Mon, 24 Oct 2016 12:46:56 +0900 (JST)
Subject: [ruby-changes:44412] nobu:r56485 (trunk): test_thread.rb: count accurately
nobu 2016-10-24 12:46:51 +0900 (Mon, 24 Oct 2016) New Revision: 56485 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56485 Log: 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. Modified files: trunk/test/ruby/test_thread.rb Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 56484) +++ test/ruby/test_thread.rb (revision 56485) @@ -836,24 +836,24 @@ _eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L836 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/