From 6b4f9210b0a105c68d98ebf2b80eea160c3af6a5 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 22 May 2014 11:49:22 +0000 Subject: * file.c (stat_birthtime): add birthtime support [Feature #9647] * file.c (rb_stat_birthtime): add File::Stat.birthtime * file.c (rb_file_s_birthtime): add File.birthtime * file.c (rb_file_birthtime): add File#birthtime * configure.in: check struct stat.st_birthtimespec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_file.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 01992a83d4..6e0930f955 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -311,6 +311,31 @@ class TestFile < Test::Unit::TestCase assert_equal(mod_time_contents, stats.mtime, bug6385) end + def test_stat + file = Tempfile.new("stat") + 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) + if stat.birthtime != stat.ctime + assert_in_delta t0, stat.birthtime.to_f, delta + end + assert_in_delta t0+2, stat.mtime.to_f, delta + assert_in_delta t0+4, stat.ctime.to_f, delta + assert_in_delta t0+6, stat.atime.to_f, delta + rescue NotImplementedError + end + def test_chmod_m17n bug5671 = '[ruby-dev:44898]' Dir.mktmpdir('test-file-chmod-m17n-') do |tmpdir| -- cgit v1.2.3