mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_io.rb (TestIO#pipe): need to propagate exceptions
in read/write thread. fix r29541. * test/ruby/test_io_m17n.rb (TestIO_M17N#pipe): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6223582f2a
commit
a012bf6ed4
3 changed files with 48 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
Wed Oct 27 13:51:25 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* test/ruby/test_io.rb (TestIO#pipe): need to propagate exceptions
|
||||
in read/write thread. fix r29541.
|
||||
|
||||
* test/ruby/test_io_m17n.rb (TestIO_M17N#pipe): ditto.
|
||||
|
||||
Wed Oct 27 12:05:40 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* class.c (clone_const): need to return value. fix r29602.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,16 +19,33 @@ class TestIO_M17N < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def pipe(*args, wp, rp)
|
||||
r, w = IO.pipe(*args)
|
||||
rt = Thread.new { rp.call(r) }
|
||||
wt = Thread.new { wp.call(w) }
|
||||
def pipe(wp, rp)
|
||||
re, we = nil, nil
|
||||
r, w = IO.pipe
|
||||
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 || 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(*args)
|
||||
|
|
Loading…
Reference in a new issue