diff options
author | Andrew Konchin <[email protected]> | 2024-06-07 19:01:53 +0300 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2024-06-10 16:00:37 +0200 |
commit | 3ebab4b64d56e9e13a2b954a7a25514fd43f0895 (patch) | |
tree | a4f9389c7b69165002e5d67e75e074ded1e30c3a /spec/ruby/library/io-wait/wait_writable_spec.rb | |
parent | e8bd745c17b809ba1a64e33fde91edd5babe4500 (diff) |
Update to ruby/spec@517f06f
Diffstat (limited to 'spec/ruby/library/io-wait/wait_writable_spec.rb')
-rw-r--r-- | spec/ruby/library/io-wait/wait_writable_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/ruby/library/io-wait/wait_writable_spec.rb b/spec/ruby/library/io-wait/wait_writable_spec.rb index 8c44780d39..8639dd717b 100644 --- a/spec/ruby/library/io-wait/wait_writable_spec.rb +++ b/spec/ruby/library/io-wait/wait_writable_spec.rb @@ -1,4 +1,5 @@ require_relative '../../spec_helper' +require_relative '../../fixtures/io' ruby_version_is ''...'3.2' do require 'io/wait' @@ -17,4 +18,24 @@ describe "IO#wait_writable" do # Represents one year and is larger than a 32-bit int STDOUT.wait_writable(365 * 24 * 60 * 60).should == STDOUT end + + it "can be interrupted" do + rd, wr = IO.pipe + IOSpec.exhaust_write_buffer(wr) + start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + + t = Thread.new do + wr.wait_writable(10) + end + + Thread.pass until t.stop? + t.kill + t.join + + finish = Process.clock_gettime(Process::CLOCK_MONOTONIC) + (finish - start).should < 9 + ensure + rd.close unless rd.closed? + wr.close unless wr.closed? + end end |