Project

General

Profile

Bug #8768 ยป 0001-lib-tempfile.rb-Tempfile-unlink-undefine-finalizer.patch

patch incuding testcase - normalperson (Eric Wong), 08/11/2013 04:41 AM

View differences:

lib/tempfile.rb
def close!
_close
unlink
ObjectSpace.undefine_finalizer(self)
end
# Unlinks (deletes) the file from the filesystem. One should always unlink
......
# remove tmpname from remover
@data[0] = @data[1] = nil
@tmpname = nil
ObjectSpace.undefine_finalizer(self)
end
alias delete unlink
test/test_tempfile.rb
end
end
def test_tempfile_finalizer_does_not_run_if_unlinked
args = %w(--debug --disable-gems -rtempfile)
assert_in_out_err(args, <<-'EOS') do |(filename), (error)|
tmp = Tempfile.new('foo')
puts tmp.path
tmp.unlink
EOS
assert !File.exist?(filename)
assert_nil error, "we used to get a confusing 'removing ...done' here"
end
end
def test_size_flushes_buffer_before_determining_file_size
t = tempfile("foo")
t.write("hello")
    (1-1/1)