mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use Tempfile.create instead of Tempfile.new.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
42c7b5f09b
commit
bef7ff9c74
1 changed files with 22 additions and 23 deletions
|
@ -313,32 +313,31 @@ class TestFile < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_stat
|
def test_stat
|
||||||
tb = Process.clock_gettime(Process::CLOCK_REALTIME)
|
tb = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||||
file = Tempfile.new("stat")
|
Tempfile.create("stat") {|file|
|
||||||
tb = (tb + Process.clock_gettime(Process::CLOCK_REALTIME)) / 2
|
tb = (tb + Process.clock_gettime(Process::CLOCK_REALTIME)) / 2
|
||||||
file.close
|
file.close
|
||||||
path = file.path
|
path = file.path
|
||||||
|
|
||||||
t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||||
File.write(path, "foo")
|
File.write(path, "foo")
|
||||||
sleep 2
|
sleep 2
|
||||||
File.write(path, "bar")
|
File.write(path, "bar")
|
||||||
sleep 2
|
sleep 2
|
||||||
File.chmod(0644, path)
|
File.chmod(0644, path)
|
||||||
sleep 2
|
sleep 2
|
||||||
File.read(path)
|
File.read(path)
|
||||||
|
|
||||||
delta = 1
|
delta = 1
|
||||||
stat = File.stat(path)
|
stat = File.stat(path)
|
||||||
assert_in_delta tb, stat.birthtime.to_f, delta
|
assert_in_delta tb, stat.birthtime.to_f, delta
|
||||||
assert_in_delta t0+2, stat.mtime.to_f, delta
|
assert_in_delta t0+2, stat.mtime.to_f, delta
|
||||||
if stat.birthtime != stat.ctime
|
if stat.birthtime != stat.ctime
|
||||||
assert_in_delta t0+4, stat.ctime.to_f, delta
|
assert_in_delta t0+4, stat.ctime.to_f, delta
|
||||||
end
|
end
|
||||||
skip "Windows delays updating atime" if /mswin|mingw/ =~ RUBY_PLATFORM
|
skip "Windows delays updating atime" if /mswin|mingw/ =~ RUBY_PLATFORM
|
||||||
assert_in_delta t0+6, stat.atime.to_f, delta
|
assert_in_delta t0+6, stat.atime.to_f, delta
|
||||||
|
}
|
||||||
rescue NotImplementedError
|
rescue NotImplementedError
|
||||||
ensure
|
|
||||||
file.close!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_chmod_m17n
|
def test_chmod_m17n
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue