8000 [Feature #21205] Implement File::Stat#birthtime on Linux by nobu · Pull Request #13474 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

[Feature #21205] Implement File::Stat#birthtime on Linux #13474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Feature #21205] Fix up birthtime in ruby/spec
  • Loading branch information
nobu committed May 30, 2025
commit 8872d3e10bc36a07dff72d0baf461992cca9b699
46 changes: 15 additions & 31 deletions spec/ruby/core/file/birthtime_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require_relative '../../spec_helper'

describe "File.birthtime" do
before :each do
@file = __FILE__
end
platform_is :windows, :darwin, :freebsd, :netbsd, :linux do
describe "File.birthtime" do
before :each do
@file = __FILE__
end

after :each do
@file = nil
end
after :each do
@file = nil
end

platform_is :windows, :darwin, :freebsd, :netbsd 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)
Expand All @@ -24,37 +24,21 @@
end
end

platform_is :openbsd do
it "raises an NotImplementedError" do
-> { File.birthtime(@file) }.should raise_error(NotImplementedError)
describe "File#birthtime" do
before :each do
@file = File.open(__FILE__)
end
end

# TODO: depends on Linux kernel version
end

describe "File#birthtime" do
before :each do
@file = File.open(__FILE__)
end

after :each do
@file.close
@file = nil
end
after :each do
@file.close
@file = nil
end

platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birth time for self" do
@file.birthtime
@file.birthtime.should be_kind_of(Time)
end
end

platform_is :openbsd do
it "raises an NotImplementedError" do
-> { @file.birthtime }.should raise_error(NotImplementedError)
end
end

# TODO: depends on Linux kernel version
end
27 changes: 11 additions & 16 deletions spec/ruby/core/file/stat/birthtime_spec.rb
9B7A
Original file line number Diff line numberDiff line change
@@ -1,27 +1,22 @@
require_relative '../../../spec_helper'

describe "File::Stat#birthtime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
platform_is(:windows, :darwin, :freebsd, :netbsd,
*ruby_version_is("3.5") { :linux },
) do
describe "File::Stat#birthtime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end

after :each do
rm_r @file
end
after :each do
rm_r @file
end

platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birthtime of a File::Stat object" do
st = File.stat(@file)
st.birthtime.should be_kind_of(Time)
st.birthtime.should <= Time.now
end
end

platform_is :linux, :openbsd do
it "raises an NotImplementedError" do
st = File.stat(@file)
-> { st.birthtime }.should raise_error(NotImplementedError)
end
end
end
Loading
0