bootstraptest/runner: speed up assert_finish by avoiding sleep
We may use IO.select to watch for process exit. This speeds up "make test" by 2 seconds for me. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8ae5c935a5
commit
a1ba5b6a64
@ -373,13 +373,18 @@ 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 = Time.now + timeout_seconds
|
tlimit = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout_seconds
|
||||||
while Time.now < tlimit
|
diff = timeout_seconds
|
||||||
|
while diff > 0
|
||||||
if Process.waitpid pid, Process::WNOHANG
|
if Process.waitpid pid, Process::WNOHANG
|
||||||
waited = true
|
waited = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
sleep 0.1
|
if IO.select([io], nil, nil, diff)
|
||||||
|
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user