diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-07 16:42:32 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-07 16:42:32 +0000 |
commit | 24a575800189c766a1d8371da03691d57de1f81b (patch) | |
tree | 6abbd2ac06da316d2f8fc30a3387e7210e2eaf02 /test | |
parent | 7d3b03f9fe11acf6d762c2066c10018f78b82a10 (diff) |
merge revision(s) 56892: [Backport #12910]
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/branches/ruby_2_3@57566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 2640eb2094..82380d434c 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -18,8 +18,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 } @@ -216,6 +219,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 |