From 4c26a38ed3c0322a3a9116ea7a32d7d48bf74727 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 1 Jun 2025 14:22:51 +0900 Subject: [PATCH] Skip birthtime failures on old linux `statx(2)` is available since Linux 4.11 and glibc 2.28. --- spec/ruby/core/file/birthtime_spec.rb | 10 ++++++++-- spec/ruby/core/file/stat/birthtime_spec.rb | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spec/ruby/core/file/birthtime_spec.rb b/spec/ruby/core/file/birthtime_spec.rb index 7f36127a94..a8a102e93e 100644 --- a/spec/ruby/core/file/birthtime_spec.rb +++ b/spec/ruby/core/file/birthtime_spec.rb @@ -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 diff --git a/spec/ruby/core/file/stat/birthtime_spec.rb b/spec/ruby/core/file/stat/birthtime_spec.rb index 82695b18c6..9fc471caec 100644 --- a/spec/ruby/core/file/stat/birthtime_spec.rb +++ b/spec/ruby/core/file/stat/birthtime_spec.rb @@ -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