mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/tempfile.rb (Tempfile#size): stat by path name when it is
closed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9ad152e555
commit
5e02a28a8b
3 changed files with 14 additions and 9 deletions
|
@ -153,7 +153,7 @@ class TestTempfile < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_finalizer_does_not_unlink_if_already_unlinked
|
||||
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename), (error)|
|
||||
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename,), (error,)|
|
||||
file = Tempfile.new('foo')
|
||||
path = file.path
|
||||
puts path
|
||||
|
@ -165,7 +165,7 @@ File.open(path, "w").close
|
|||
assert_nil error
|
||||
end
|
||||
|
||||
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename), (error)|
|
||||
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename,), (error,)|
|
||||
file = Tempfile.new('foo')
|
||||
path = file.path
|
||||
file.unlink
|
||||
|
@ -191,11 +191,11 @@ File.open(path, "w").close
|
|||
t = tempfile("foo")
|
||||
t.write("hello")
|
||||
t.close
|
||||
assert 5, File.size(t.path)
|
||||
assert_equal 5, File.size(t.path)
|
||||
end
|
||||
|
||||
def test_tempfile_is_unlinked_when_ruby_exits
|
||||
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename), (error)|
|
||||
assert_in_out_err('-rtempfile', <<-'EOS') do |(filename,), (error,)|
|
||||
puts Tempfile.new('foo').path
|
||||
EOS
|
||||
assert !File.exist?(filename)
|
||||
|
@ -205,16 +205,16 @@ puts Tempfile.new('foo').path
|
|||
def test_size_flushes_buffer_before_determining_file_size
|
||||
t = tempfile("foo")
|
||||
t.write("hello")
|
||||
assert 0, File.size(t.path)
|
||||
assert 5, t.size
|
||||
assert 5, File.size(t.path)
|
||||
assert_equal 0, File.size(t.path)
|
||||
assert_equal 5, t.size
|
||||
assert_equal 5, File.size(t.path)
|
||||
end
|
||||
|
||||
def test_size_works_if_file_is_closed
|
||||
t = tempfile("foo")
|
||||
t.write("hello")
|
||||
t.close
|
||||
assert 5, t.size
|
||||
assert_equal 5, t.size
|
||||
end
|
||||
|
||||
def test_concurrency
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue