diff options
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r-- | test/ruby/test_io.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 34ac67db6b..b692c91c7b 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -23,15 +23,32 @@ class TestIO < Test::Unit::TestCase end def pipe(wp, rp) + re, we = nil, nil r, w = IO.pipe - rt = Thread.new { rp.call(r) } - wt = Thread.new { wp.call(w) } + rt = Thread.new do + begin + rp.call(r) + rescue Exception + r.close + re = $! + end + end + wt = Thread.new do + begin + wp.call(w) + rescue Exception + w.close + we = $! + end + end flunk("timeout") unless rt.join(10) && wt.join(10) ensure r.close unless !r || r.closed? w.close unless !w || w.closed? (rt.kill; rt.join) if rt (wt.kill; wt.join) if wt + raise re if re + raise we if we end def with_pipe |