summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-31 14:44:40 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-31 14:44:40 +0000
commitd1eababd7b88c231fff52b9c1edf49d4f296498c (patch)
treeb7f36332442df922961dcdcfb0d21edf59296869 /test
parent67f6196b8bf68b106940f1bc71e6c74aac8bde16 (diff)
merge revision(s) 43110,43155: [Backport #8768]
* lib/tempfile.rb (Tempfile#unlink): finalizer is no longer needed after unlinking. patched by by normalperson (Eric Wong) at [ruby-core:56521] [Bug #8768] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@43490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_tempfile.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb
index 1462a981f7..c6cbbeeeeb 100644
--- a/test/test_tempfile.rb
+++ b/test/test_tempfile.rb
@@ -206,6 +206,21 @@ puts Tempfile.new('foo').path
end
end
+ def test_tempfile_finalizer_does_not_run_if_unlinked
+ bug8768 = '[ruby-core:56521] [Bug #8768]'
+ args = %w(--disable-gems -rtempfile)
+ assert_in_out_err(args, <<-'EOS') do |(filename), (error)|
+ tmp = Tempfile.new('foo')
+ puts tmp.path
+ tmp.close
+ tmp.unlink
+ $DEBUG = true
+ EOS
+ refute File.exist?(filename)
+ assert_nil(error, "#{bug8768} 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")