diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-24 03:01:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-24 03:01:59 +0000 |
commit | 4aefcbc5327be0f66ba8b1d9494c1573e52ab839 (patch) | |
tree | 70ff47617efe7ba549180c985e2fc0b8d142edb6 /test/fileutils | |
parent | 94ca443a627a444219b8eaaeadfe4d3dd5b487dc (diff) |
test_fileutils.rb: fix deadlock
* test/fileutils/test_fileutils.rb (assert_output_lines): ensure
that write pipe is closed, not the reader thread to deadlock
when an exception raised in the given block.
[ruby-core:78053] [Bug #12910]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils')
-rw-r--r-- | test/fileutils/test_fileutils.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index fedf5d4780..4d790a74bc 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -17,8 +17,11 @@ class TestFileUtils < Test::Unit::TestCase fu.instance_variable_set(:@fileutils_output, write) th = Thread.new { read.read } th2 = Thread.new { - yield - write.close + begin + yield + ensure + write.close + end } th_value, _ = assert_join_threads([th, th2]) lines = th_value.lines.map {|l| l.chomp } @@ -213,6 +216,16 @@ class TestFileUtils < Test::Unit::TestCase # Test Cases # + def test_assert_output_lines + assert_raise(MiniTest::Assertion) { + Timeout.timeout(0.1) { + assert_output_lines([]) { + raise "ok" + } + } + } + end + def test_pwd check_singleton :pwd |