diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-22 11:49:22 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-22 11:49:22 +0000 |
commit | 6b4f9210b0a105c68d98ebf2b80eea160c3af6a5 (patch) | |
tree | 3377fcaa4c7cdfa2d82dd97cd2fccbdb210954b4 /test | |
parent | a999657e7e72d21c5904b2dd5bc056619aff2b81 (diff) |
* 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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_file.rb | 25 |
1 files changed, 25 insertions, 0 deletions
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| |