From ebfc44852988873c4e3b8cf70f706574e9d186f2 Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 30 Jul 2018 08:05:22 +0000 Subject: 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 --- bootstraptest/runner.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'bootstraptest') 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) -- cgit v1.2.3