-
Notifications
You must be signed in to change notification settings - Fork 20
Run pathname specs from ruby/spec in CI and fix them #60
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
Conversation
|
I also compared methods before and after #57: diff methods_old.txt methods_new.txt
50d49
< lutime
60a60
> path
|
|
Ah and there is another bug in |
e9e8d7b to
da66ef7
Compare
* 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
|
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. |
|
👍 |
|
I'll merge this, it fixes 3 major issues with testing in ruby/pathname:
|
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.