1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2016-11-24 03:01:59 +00:00
parent 94ca443a62
commit 4aefcbc532

View file

@ -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