Run pathname specs from ruby/spec in CI and fix them#60
Merged
eregon merged 9 commits intoruby:masterfrom Aug 26, 2025
Merged
Conversation
Member
Author
|
I also compared methods before and after #57: diff methods_old.txt methods_new.txt
50d49
< lutime
60a60
> path
|
Member
Author
|
Ah and there is another bug in |
e9e8d7b to
da66ef7
Compare
This was referenced Aug 23, 2025
byroot
approved these changes
Aug 23, 2025
* Provides extra testing and coverage.
* Found by ruby/spec, and confirmed pathname.c did the same.
* Found by ruby/spec, and confirmed pathname.c did the same.
* This has no test in test_pathname.rb, that is why it was missed. * Found by ruby/spec, and confirmed pathname.c did the same.
* This reverts commit a9ef32e. * It is already added in Ruby code.
* There is no point to call IO.sysopen and that's the last IO method, with Pathname we know it's always a file path.
* jruby/jruby#8972 but also at least 2 more incompatibilities.
df5fe00 to
ef196cc
Compare
Member
Author
|
I rebased this on top of #61, there were many conflicts. diff --git a/lib/pathname.rb b/lib/pathname.rb
index 1c4ec6e..a0db812 100644
--- a/lib/pathname.rb
+++ b/lib/pathname.rb
@@ -210,6 +210,7 @@ require 'pathname.so' if RUBY_ENGINE == 'ruby'
#
class Pathname
+ # The version string.
VERSION = "0.4.0"
# :stopdoc:
@@ -338,14 +339,42 @@ class Pathname
end
if File.dirname('A:') == 'A:.' # DOSish drive letter
- ABSOLUTE_PATH = /\A(?:[A-Za-z]:|#{SEPARATOR_PAT})/o
+ ABSOLUTE_PATH = /\A(?:[A-Za-z]:|#{SEPARATOR_PAT})/
else
- ABSOLUTE_PATH = /\A#{SEPARATOR_PAT}/o
+ ABSOLUTE_PATH = /\A#{SEPARATOR_PAT}/
end
private_constant :ABSOLUTE_PATH
# :startdoc:
+ # Creates a full path, including any intermediate directories that don't yet
+ # exist.
+ #
+ # See FileUtils.mkpath and FileUtils.mkdir_p
+ def mkpath(mode: nil)
+ path = @path == '/' ? @path : @path.chomp('/')
+
+ stack = []
+ until File.directory?(path) || File.dirname(path) == path
+ stack.push path
+ path = File.dirname(path)
+ end
+
+ stack.reverse_each do |dir|
+ dir = dir == '/' ? dir : dir.chomp('/')
+ if mode
+ Dir.mkdir dir, mode
+ File.chmod mode, dir
+ else
+ Dir.mkdir dir
+ end
+ rescue SystemCallError
+ raise unless File.directory?(dir)
+ end
+
+ self
+ end
+
# chop_basename(path) -> [pre-basename, basename] or nil
def chop_basename(path) # :nodoc:
base = File.basename(path)
@@ -1167,16 +1196,6 @@ end
class Pathname # * FileUtils *
- # Creates a full path, including any intermediate directories that don't yet
- # exist.
- #
- # See FileUtils.mkpath and FileUtils.mkdir_p
- def mkpath(mode: nil)
- require 'fileutils'
- FileUtils.mkpath(@path, mode: mode)
- self
- end
-
# Recursively deletes a directory, including all directories beneath it.
#
# See FileUtils.rm_rfWhich is expected changes upstreamed from ruby/ruby. |
Member
|
👍 |
Member
Author
|
I'll merge this, it fixes 3 major issues with testing in ruby/pathname:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Includes the fixes from ruby/ruby#14303, although some of them are done slightly differently to match the semantics from pathname.c closer.
See #60 (comment) for the summary of what this PR does.