Revert "bootstraptest/runner: speed up assert_finish by avoiding sleep"

This reverts commit r63754.
Many CI servers still use old ruby as base ruby which does not support
read_nonblock.

https://rubyci.org/logs/www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20180627T013100Z.fail.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2018-06-27 02:37:26 +00:00
parent 529af9c821
commit e3e22c551d

View File

@ -373,18 +373,13 @@ def assert_finish(timeout_seconds, testsrc, message = '')
io = IO.popen("#{@ruby} -W0 #{filename}") io = IO.popen("#{@ruby} -W0 #{filename}")
pid = io.pid pid = io.pid
waited = false waited = false
tlimit = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout_seconds tlimit = Time.now + timeout_seconds
diff = timeout_seconds while Time.now < tlimit
while diff > 0
if Process.waitpid pid, Process::WNOHANG if Process.waitpid pid, Process::WNOHANG
waited = true waited = true
break break
end end
if IO.select([io], nil, nil, diff) sleep 0.1
while String === io.read_nonblock(1024, exception: false)
end
end
diff = tlimit - Process.clock_gettime(Process::CLOCK_MONOTONIC)
end end
if !waited if !waited
Process.kill(:KILL, pid) Process.kill(:KILL, pid)