ruby-changes:44819
From: nobu <ko1@a...>
Date: Thu, 24 Nov 2016 12:02:05 +0900 (JST)
Subject: [ruby-changes:44819] nobu:r56892 (trunk): test_fileutils.rb: fix deadlock
nobu 2016-11-24 12:01:59 +0900 (Thu, 24 Nov 2016) New Revision: 56892 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56892 Log: 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] Modified files: trunk/test/fileutils/test_fileutils.rb Index: test/fileutils/test_fileutils.rb =================================================================== --- test/fileutils/test_fileutils.rb (revision 56891) +++ test/fileutils/test_fileutils.rb (revision 56892) @@ -17,8 +17,11 @@ class TestFileUtils < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L17 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::TestCa https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L216 # 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/