ruby-changes:17602
From: usa <ko1@a...>
Date: Wed, 27 Oct 2010 13:53:45 +0900 (JST)
Subject: [ruby-changes:17602] Ruby:r29607 (trunk): * test/ruby/test_io.rb (TestIO#pipe): need to propagate exceptions
usa 2010-10-27 13:53:34 +0900 (Wed, 27 Oct 2010) New Revision: 29607 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29607 Log: * 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. Modified files: trunk/ChangeLog trunk/test/ruby/test_io.rb trunk/test/ruby/test_io_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 29606) +++ ChangeLog (revision 29607) @@ -1,3 +1,10 @@ +Wed Oct 27 13:51:25 2010 NAKAMURA Usaku <usa@r...> + + * 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@r...> * class.c (clone_const): need to return value. fix r29602. Index: test/ruby/test_io_m17n.rb =================================================================== --- test/ruby/test_io_m17n.rb (revision 29606) +++ test/ruby/test_io_m17n.rb (revision 29607) @@ -19,16 +19,33 @@ } 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) Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 29606) +++ test/ruby/test_io.rb (revision 29607) @@ -23,15 +23,32 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/