[Feature #21205] Fix up birthtime in ruby/spec

This commit is contained in:
Nobuyoshi Nakada 2025-05-10 15:40:24 +09:00
parent 18a036a613
commit 8872d3e10b
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465
Notes: git 2025-05-30 13:00:32 +00:00
2 changed files with 26 additions and 47 deletions

View file

@ -1,15 +1,15 @@
require_relative '../../spec_helper' require_relative '../../spec_helper'
describe "File.birthtime" do platform_is :windows, :darwin, :freebsd, :netbsd, :linux do
before :each do describe "File.birthtime" do
@file = __FILE__ before :each do
end @file = __FILE__
end
after :each do after :each do
@file = nil @file = nil
end end
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birth time for the named file as a Time object" do it "returns the birth time for the named file as a Time object" do
File.birthtime(@file) File.birthtime(@file)
File.birthtime(@file).should be_kind_of(Time) File.birthtime(@file).should be_kind_of(Time)
@ -24,37 +24,21 @@ describe "File.birthtime" do
end end
end end
platform_is :openbsd do describe "File#birthtime" do
it "raises an NotImplementedError" do before :each do
-> { File.birthtime(@file) }.should raise_error(NotImplementedError) @file = File.open(__FILE__)
end end
end
# TODO: depends on Linux kernel version after :each do
end @file.close
@file = nil
end
describe "File#birthtime" do
before :each do
@file = File.open(__FILE__)
end
after :each do
@file.close
@file = nil
end
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birth time for self" do it "returns the birth time for self" do
@file.birthtime @file.birthtime
@file.birthtime.should be_kind_of(Time) @file.birthtime.should be_kind_of(Time)
end end
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 # TODO: depends on Linux kernel version
end end

View file

@ -1,27 +1,22 @@
require_relative '../../../spec_helper' require_relative '../../../spec_helper'
describe "File::Stat#birthtime" do platform_is(:windows, :darwin, :freebsd, :netbsd,
before :each do *ruby_version_is("3.5") { :linux },
@file = tmp('i_exist') ) do
touch(@file) { |f| f.write "rubinius" } describe "File::Stat#birthtime" do
end before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do after :each do
rm_r @file rm_r @file
end end
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birthtime of a File::Stat object" do it "returns the birthtime of a File::Stat object" do
st = File.stat(@file) st = File.stat(@file)
st.birthtime.should be_kind_of(Time) st.birthtime.should be_kind_of(Time)
st.birthtime.should <= Time.now st.birthtime.should <= Time.now
end end
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 end