Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebfc448

Browse files
author
normal
committed
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
1 parent ab740cb commit ebfc448

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

bootstraptest/runner.rb

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Never use optparse in this file.
77
# Never use test/unit in this file.
88
# Never use Ruby extensions in this file.
9+
# Maintain Ruby 1.8 compatibility for now
910

1011
begin
1112
require 'fileutils'
@@ -374,12 +375,24 @@ def assert_finish(timeout_seconds, testsrc, message = '')
374375
pid = io.pid
375376
waited = false
376377
tlimit = Time.now + timeout_seconds
377-
while Time.now < tlimit
378+
diff = timeout_seconds
379+
while diff > 0
378380
if Process.waitpid pid, Process::WNOHANG
379381
waited = true
380382
break
381383
end
382-
sleep 0.1
384+
if io.respond_to?(:read_nonblock)
385+
if IO.select([io], nil, nil, diff)
386+
begin
387+
io.read_nonblock(1024)
388+
rescue Errno::EAGAIN, EOFError
389+
break
390+
end while true
391+
end
392+
else
393+
sleep 0.1
394+
end
395+
diff = tlimit - Time.now
383396
end
384397
if !waited
385398
Process.kill(:KILL, pid)

0 commit comments

Comments
 (0)