Skip birthtime failures on old linux

`statx(2)` is available since Linux 4.11 and glibc 2.28.
This commit is contained in:
Nobuyoshi Nakada 2025-06-01 14:22:51 +09:00
parent 1395abd025
commit 4c26a38ed3
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2025-06-01 06:45:33 +00:00
2 changed files with 10 additions and 2 deletions

View File

@ -13,14 +13,20 @@ platform_is :windows, :darwin, :freebsd, :netbsd, :linux do
it "returns the birth time for the named file as a Time object" do
File.birthtime(@file)
File.birthtime(@file).should be_kind_of(Time)
rescue NotImplementedError => e
skip e.message if e.message.start_with?("birthtime() function")
end
it "accepts an object that has a #to_path method" do
File.birthtime(mock_to_path(@file))
rescue NotImplementedError => e
skip e.message if e.message.start_with?("birthtime() function")
end
it "raises an Errno::ENOENT exception if the file is not found" do
-> { File.birthtime('bogus') }.should raise_error(Errno::ENOENT)
rescue NotImplementedError => e
skip e.message if e.message.start_with?("birthtime() function")
end
end
@ -37,8 +43,8 @@ platform_is :windows, :darwin, :freebsd, :netbsd, :linux do
it "returns the birth time for self" do
@file.birthtime
@file.birthtime.should be_kind_of(Time)
rescue NotImplementedError => e
skip e.message if e.message.start_with?("birthtime() function")
end
end
# TODO: depends on Linux kernel version
end

View File

@ -17,6 +17,8 @@ platform_is(:windows, :darwin, :freebsd, :netbsd,
st = File.stat(@file)
st.birthtime.should be_kind_of(Time)
st.birthtime.should <= Time.now
rescue NotImplementedError => e
skip e.message if e.message.start_with?("birthtime() function")
end
end
end