mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_file.rb: estimate birthtime
* test/ruby/test_file.rb (test_stat): estimate expected birthtime by pinching. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
90fb7538f8
commit
c70edbef91
1 changed files with 3 additions and 1 deletions
|
@ -312,7 +312,9 @@ class TestFile < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_stat
|
def test_stat
|
||||||
|
tb = Process.clock_gettime(Process::CLOCK_REALTIME)
|
||||||
file = Tempfile.new("stat")
|
file = Tempfile.new("stat")
|
||||||
|
tb = (tb + Process.clock_gettime(Process::CLOCK_REALTIME)) / 2
|
||||||
file.close
|
file.close
|
||||||
path = file.path
|
path = file.path
|
||||||
|
|
||||||
|
@ -328,7 +330,7 @@ class TestFile < Test::Unit::TestCase
|
||||||
delta = 1
|
delta = 1
|
||||||
stat = File.stat(path)
|
stat = File.stat(path)
|
||||||
if stat.birthtime != stat.ctime
|
if stat.birthtime != stat.ctime
|
||||||
assert_in_delta t0, stat.birthtime.to_f, delta
|
assert_in_delta tb, stat.birthtime.to_f, delta
|
||||||
end
|
end
|
||||||
assert_in_delta t0+2, stat.mtime.to_f, delta
|
assert_in_delta t0+2, stat.mtime.to_f, delta
|
||||||
assert_in_delta t0+4, stat.ctime.to_f, delta
|
assert_in_delta t0+4, stat.ctime.to_f, delta
|
||||||
|
|
Loading…
Add table
Reference in a new issue