diff options
author | Benoit Daloze <[email protected]> | 2019-05-28 22:41:48 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2019-05-28 22:41:48 +0200 |
commit | a66bc2c01194a9c017c874a30db5b3b6bd95e966 (patch) | |
tree | 598d6375b44fd86f90c3477c73086f6fcf08d76c /spec/ruby/library/socket/fixtures/classes.rb | |
parent | d070523e7be4b95914adeef9a10401fba7718c5a (diff) |
Update to ruby/spec@9a501a8
Diffstat (limited to 'spec/ruby/library/socket/fixtures/classes.rb')
-rw-r--r-- | spec/ruby/library/socket/fixtures/classes.rb | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/spec/ruby/library/socket/fixtures/classes.rb b/spec/ruby/library/socket/fixtures/classes.rb index 4cfa084333..6cc7ecb389 100644 --- a/spec/ruby/library/socket/fixtures/classes.rb +++ b/spec/ruby/library/socket/fixtures/classes.rb @@ -72,24 +72,11 @@ module SocketSpecs end def self.loop_with_timeout(timeout = TIME_TOLERANCE) - require 'timeout' - time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = Process.clock_gettime(Process::CLOCK_MONOTONIC) - loop do - if Process.clock_gettime(Process::CLOCK_MONOTONIC) - time >= timeout - raise TimeoutError, "Did not succeed within #{timeout} seconds" - end - - sleep 0.01 # necessary on OSX; don't know why - yield - end - end - - def self.wait_until_success(timeout = TIME_TOLERANCE) - loop_with_timeout(timeout) do - begin - return yield - rescue + while yield == :retry + if Process.clock_gettime(Process::CLOCK_MONOTONIC) - start >= timeout + raise RuntimeError, "Did not succeed within #{timeout} seconds" end end end |