Skip to content

Commit 4c26a38

Browse files
committed
Skip birthtime failures on old linux
`statx(2)` is available since Linux 4.11 and glibc 2.28.
1 parent 1395abd commit 4c26a38

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

spec/ruby/core/file/birthtime_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
it "returns the birth time for the named file as a Time object" do
1414
File.birthtime(@file)
1515
File.birthtime(@file).should be_kind_of(Time)
16+
rescue NotImplementedError => e
17+
skip e.message if e.message.start_with?("birthtime() function")
1618
end
1719

1820
it "accepts an object that has a #to_path method" do
1921
File.birthtime(mock_to_path(@file))
22+
rescue NotImplementedError => e
23+
skip e.message if e.message.start_with?("birthtime() function")
2024
end
2125

2226
it "raises an Errno::ENOENT exception if the file is not found" do
2327
-> { File.birthtime('bogus') }.should raise_error(Errno::ENOENT)
28+
rescue NotImplementedError => e
29+
skip e.message if e.message.start_with?("birthtime() function")
2430
end
2531
end
2632

@@ -37,8 +43,8 @@
3743
it "returns the birth time for self" do
3844
@file.birthtime
3945
@file.birthtime.should be_kind_of(Time)
46+
rescue NotImplementedError => e
47+
skip e.message if e.message.start_with?("birthtime() function")
4048
end
4149
end
42-
43-
# TODO: depends on Linux kernel version
4450
end

spec/ruby/core/file/stat/birthtime_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
st = File.stat(@file)
1818
st.birthtime.should be_kind_of(Time)
1919
st.birthtime.should <= Time.now
20+
rescue NotImplementedError => e
21+
skip e.message if e.message.start_with?("birthtime() function")
2022
end
2123
end
2224
end

0 commit comments

Comments
 (0)