From defcaf89dd9ed860f8ac00508ff80bcde86645a1 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 29 Nov 2017 09:59:20 +0000 Subject: file.c: File.lutime * file.c (utime_internal): add File.lutime. [Feature #4052] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_file_exhaustive.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 4c5540eb4c..6f2fbb1bd2 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -647,6 +647,36 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal(t + 2, File.mtime(zerofile)) end + def test_utime_symlinkfile + return unless symlinkfile + t = Time.local(2000) + stat = File.lstat(symlinkfile) + assert_equal(File.utime(t, t, symlinkfile), 1) + assert_equal(File.stat(regular_file).atime, t) + assert_equal(File.stat(regular_file).mtime, t) + assert_equal(File.lstat(symlinkfile).atime, stat.atime) + assert_equal(File.lstat(symlinkfile).mtime, stat.mtime) + end + + def test_lutime + return unless File.respond_to?(:lutime) + return unless symlinkfile + + r = File.stat(regular_file) + t = Time.local(2000) + File.lutime(t + 1, t + 2, symlinkfile) + rescue NotImplementedError => e + skip(e.message) + else + stat = File.stat(regular_file) + assert_equal(r.atime, stat.atime) + assert_equal(r.mtime, stat.mtime) + + stat = File.lstat(symlinkfile) + assert_equal(t + 1, stat.atime) + assert_equal(t + 2, stat.mtime) + end + def test_hardlink return unless hardlinkfile assert_equal("file", File.ftype(hardlinkfile)) -- cgit v1.2.3