summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-26 14:45:51 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-26 14:45:51 +0000
commitbef7ff9c7468f64382a141cdffdb34b33894f43c (patch)
tree9cd6d61f26dfbead2cc5d8897f5cb3d66268e0c3 /test
parent42c7b5f09b3c661181215cf1cf9b918c3de2bcfb (diff)
Use Tempfile.create instead of Tempfile.new.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_file.rb49
1 files changed, 24 insertions, 25 deletions
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index 51fffadb68..9462ae597b 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -313,32 +313,31 @@ class TestFile < Test::Unit::TestCase
def test_stat
tb = Process.clock_gettime(Process::CLOCK_REALTIME)
- file = Tempfile.new("stat")
- tb = (tb + Process.clock_gettime(Process::CLOCK_REALTIME)) / 2
- file.close
- path = file.path
-
- t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
- File.write(path, "foo")
- sleep 2
- File.write(path, "bar")
- sleep 2
- File.chmod(0644, path)
- sleep 2
- File.read(path)
-
- delta = 1
- stat = File.stat(path)
- assert_in_delta tb, stat.birthtime.to_f, delta
- assert_in_delta t0+2, stat.mtime.to_f, delta
- if stat.birthtime != stat.ctime
- assert_in_delta t0+4, stat.ctime.to_f, delta
- end
- skip "Windows delays updating atime" if /mswin|mingw/ =~ RUBY_PLATFORM
- assert_in_delta t0+6, stat.atime.to_f, delta
+ Tempfile.create("stat") {|file|
+ tb = (tb + Process.clock_gettime(Process::CLOCK_REALTIME)) / 2
+ file.close
+ path = file.path
+
+ t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
+ File.write(path, "foo")
+ sleep 2
+ File.write(path, "bar")
+ sleep 2
+ File.chmod(0644, path)
+ sleep 2
+ File.read(path)
+
+ delta = 1
+ stat = File.stat(path)
+ assert_in_delta tb, stat.birthtime.to_f, delta
+ assert_in_delta t0+2, stat.mtime.to_f, delta
+ if stat.birthtime != stat.ctime
+ assert_in_delta t0+4, stat.ctime.to_f, delta
+ end
+ skip "Windows delays updating atime" if /mswin|mingw/ =~ RUBY_PLATFORM
+ assert_in_delta t0+6, stat.atime.to_f, delta
+ }
rescue NotImplementedError
- ensure
- file.close!
end
def test_chmod_m17n