Skip to content

Commit da66ef7

Browse files
committed
Fix Pathname#lutime test and add the method back
1 parent 08e3d92 commit da66ef7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/pathname.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,13 @@ def truncate(length) File.truncate(@path, length) end
952952
# See <tt>File.utime</tt>. Update the access and modification times.
953953
def utime(atime, mtime) File.utime(atime, mtime, @path) end
954954

955+
# Update the access and modification times of the file.
956+
#
957+
# Same as Pathname#utime, but does not follow symbolic links.
958+
#
959+
# See File.lutime.
960+
def lutime(atime, mtime) File.lutime(atime, mtime, @path) end
961+
955962
# See <tt>File.basename</tt>. Returns the last component of the path.
956963
def basename(...) self.class.new(File.basename(@path, ...)) end
957964

test/pathname/test_pathname.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,11 @@ def test_lutime
10541054
latime = Time.utc(2000)
10551055
lmtime = Time.utc(1999)
10561056
File.symlink("a", "l")
1057-
Pathname("l").utime(latime, lmtime)
1057+
begin
1058+
Pathname("l").lutime(latime, lmtime)
1059+
rescue NotImplementedError
1060+
next
1061+
end
10581062
s = File.lstat("a")
10591063
ls = File.lstat("l")
10601064
assert_equal(atime, s.atime)

0 commit comments

Comments
 (0)