mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_io.rb (test_autoclose_true_closed_by_finalizer,
test_autoclose_true_closed_by_finalizer): skip if IO objects are not recycled yet. [ruby-dev:45098] [Bug #5850] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c572ed2d25
commit
71935466b7
2 changed files with 39 additions and 10 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue Jan 10 02:19:22 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||
|
||||
* test/ruby/test_io.rb (test_autoclose_true_closed_by_finalizer,
|
||||
test_autoclose_true_closed_by_finalizer): skip if IO objects are
|
||||
not recycled yet. [ruby-dev:45098] [Bug #5850]
|
||||
|
||||
Tue Jan 10 00:41:28 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||
|
||||
* lib/tempfile.rb (Tempfile#_close): clear @tempfile and @data[1] even
|
||||
|
|
|
@ -6,6 +6,7 @@ require 'socket'
|
|||
require 'stringio'
|
||||
require 'timeout'
|
||||
require 'tempfile'
|
||||
require 'weakref'
|
||||
require_relative 'envutil'
|
||||
|
||||
class TestIO < Test::Unit::TestCase
|
||||
|
@ -1410,12 +1411,11 @@ class TestIO < Test::Unit::TestCase
|
|||
|
||||
def try_fdopen(fd, autoclose = true, level = 100)
|
||||
if level > 0
|
||||
try_fdopen(fd, autoclose, level - 1)
|
||||
f = try_fdopen(fd, autoclose, level - 1)
|
||||
GC.start
|
||||
level
|
||||
f
|
||||
else
|
||||
IO.for_fd(fd, autoclose: autoclose)
|
||||
nil
|
||||
WeakRef.new(IO.for_fd(fd, autoclose: autoclose))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1429,7 +1429,7 @@ class TestIO < Test::Unit::TestCase
|
|||
f.autoclose = false
|
||||
assert_equal(false, f.autoclose?)
|
||||
f.close
|
||||
assert_nothing_raised(Errno::EBADF) {t.close}
|
||||
assert_nothing_raised(Errno::EBADF, feature2250) {t.close}
|
||||
|
||||
t.open
|
||||
f = IO.for_fd(t.fileno, autoclose: false)
|
||||
|
@ -1437,15 +1437,38 @@ class TestIO < Test::Unit::TestCase
|
|||
f.autoclose = true
|
||||
assert_equal(true, f.autoclose?)
|
||||
f.close
|
||||
assert_raise(Errno::EBADF) {t.close}
|
||||
assert_raise(Errno::EBADF, feature2250) {t.close}
|
||||
end
|
||||
|
||||
def test_autoclose_true_closed_by_finalizer
|
||||
feature2250 = '[ruby-core:26222]'
|
||||
pre = 'ft2250'
|
||||
t = Tempfile.new(pre)
|
||||
try_fdopen(t.fileno)
|
||||
assert_raise(Errno::EBADF) {t.close}
|
||||
w = try_fdopen(t.fileno)
|
||||
begin
|
||||
w.close
|
||||
begin
|
||||
t.close
|
||||
rescue Errno::EBADF
|
||||
end
|
||||
skip "expect IO object was GC'ed but not recycled yet"
|
||||
rescue WeakRef::RefError
|
||||
assert_raise(Errno::EBADF, feature2250) {t.close}
|
||||
end
|
||||
end
|
||||
|
||||
def test_autoclose_false_closed_by_finalizer
|
||||
feature2250 = '[ruby-core:26222]'
|
||||
pre = 'ft2250'
|
||||
t = Tempfile.new(pre)
|
||||
try_fdopen(t.fileno, false)
|
||||
assert_nothing_raised(Errno::EBADF) {t.close}
|
||||
w = try_fdopen(t.fileno, false)
|
||||
begin
|
||||
w.close
|
||||
t.close
|
||||
skip "expect IO object was GC'ed but not recycled yet"
|
||||
rescue WeakRef::RefError
|
||||
assert_nothing_raised(Errno::EBADF, feature2250) {t.close}
|
||||
end
|
||||
end
|
||||
|
||||
def test_open_redirect
|
||||
|
|
Loading…
Add table
Reference in a new issue