summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-24 03:46:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-24 03:46:51 +0000
commite62586fd744f16458c82d12656f90a1a5a809fa1 (patch)
treedcc1021ccee5c31b7a9379b34ab67925c0b14572 /test
parent3bf10b0464a1ec76e0e4c0e80cad79625e9dd67e (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_thread.rb10
1 files changed, 5 insertions, 5 deletions
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