summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-30 08:05:22 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-30 08:05:22 +0000
commitebfc44852988873c4e3b8cf70f706574e9d186f2 (patch)
tree041eb4822e7ce26f2fb3645f41a0faf3b964dac6
parentab740cbb75c256e7a209f618857e136df78c6a88 (diff)
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
-rwxr-xr-xbootstraptest/runner.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index 55812031e8..a5d5d219cf 100755
--- a/bootstraptest/runner.rb
+++ b/bootstraptest/runner.rb
@@ -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)