diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-26 23:44:00 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-26 23:44:00 +0000 |
commit | a1ba5b6a649a371e9b632cb29cc0547dbe17cade (patch) | |
tree | ee459bbbb49bc3813d5b842919414137b045c870 /bootstraptest | |
parent | 8ae5c935a592456a9bb18baaa15658c07b7727dd (diff) |
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
Diffstat (limited to 'bootstraptest')
-rwxr-xr-x | bootstraptest/runner.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index e807ce5b62..29dfef771a 100755 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -373,13 +373,18 @@ def assert_finish(timeout_seconds, testsrc, message = '') io = IO.popen("#{@ruby} -W0 #{filename}") pid = io.pid waited = false - tlimit = Time.now + timeout_seconds - while Time.now < tlimit + tlimit = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout_seconds + diff = timeout_seconds + while diff > 0 if Process.waitpid pid, Process::WNOHANG waited = true break 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 if !waited Process.kill(:KILL, pid) |