mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
bootstraptest/runner.rb: speed up assert_finish with IO.select (take #2)
Resurrect r63754 in a 1.8-compatible way. While we're at it, add a note to maintain 1.8 compatibility (cf. r63757). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ab740cbb75
commit
ebfc448529
1 changed files with 15 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
# Never use optparse in this file.
|
||||
# Never use test/unit in this file.
|
||||
# Never use Ruby extensions in this file.
|
||||
# Maintain Ruby 1.8 compatibility for now
|
||||
|
||||
begin
|
||||
require 'fileutils'
|
||||
|
@ -374,12 +375,24 @@ def assert_finish(timeout_seconds, testsrc, message = '')
|
|||
pid = io.pid
|
||||
waited = false
|
||||
tlimit = Time.now + timeout_seconds
|
||||
while Time.now < tlimit
|
||||
diff = timeout_seconds
|
||||
while diff > 0
|
||||
if Process.waitpid pid, Process::WNOHANG
|
||||
waited = true
|
||||
break
|
||||
end
|
||||
sleep 0.1
|
||||
if io.respond_to?(:read_nonblock)
|
||||
if IO.select([io], nil, nil, diff)
|
||||
begin
|
||||
io.read_nonblock(1024)
|
||||
rescue Errno::EAGAIN, EOFError
|
||||
break
|
||||
end while true
|
||||
end
|
||||
else
|
||||
sleep 0.1
|
||||
end
|
||||
diff = tlimit - Time.now
|
||||
end
|
||||
if !waited
|
||||
Process.kill(:KILL, pid)
|
||||
|
|
Loading…
Reference in a new issue