summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-27 04:53:34 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-27 04:53:34 +0000
commita012bf6ed432028dd3fe8fc75dc7451c23407151 (patch)
tree4d018b43cc34f4f28bf8543a3307afb18f2dea44 /test/ruby
parent6223582f2a114f89642ba22daec25b3976b4ae51 (diff)
* 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
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb21
-rw-r--r--test/ruby/test_io_m17n.rb27
2 files changed, 41 insertions, 7 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
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index 16195699e3..2ab36cb172 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -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)