mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Refine dirname test on Windows
- Compare with the root of the target file - Fix root path of UNC path
This commit is contained in:
parent
5cf7d948ad
commit
ce0d5cc069
Notes:
git
2025-04-09 13:49:37 +00:00
1 changed files with 5 additions and 3 deletions
|
@ -6,7 +6,8 @@ require "socket"
|
|||
require '-test-/file'
|
||||
|
||||
class TestFileExhaustive < Test::Unit::TestCase
|
||||
DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i]
|
||||
ROOT_REGEXP = %r'\A(?:[a-z]:(?=(/))|//[^/]+/[^/]+)'i
|
||||
DRIVE = Dir.pwd[ROOT_REGEXP]
|
||||
POSIX = /cygwin|mswin|bccwin|mingw|emx/ !~ RUBY_PLATFORM
|
||||
NTFS = !(/mingw|mswin|bccwin/ !~ RUBY_PLATFORM)
|
||||
|
||||
|
@ -1279,8 +1280,9 @@ class TestFileExhaustive < Test::Unit::TestCase
|
|||
assert_equal(@dir, File.dirname(regular_file, 1))
|
||||
assert_equal(File.dirname(@dir), File.dirname(regular_file, 2))
|
||||
assert_raise(ArgumentError) {File.dirname(regular_file, -1)}
|
||||
# mswin allows rootdir and tmpdir are in different drives
|
||||
assert_equal(rootdir, File.dirname(regular_file, regular_file.count('/'))) unless /mswin/ =~ RUBY_PLATFORM
|
||||
root = "#{@dir[ROOT_REGEXP]||?/}#{$1}"
|
||||
assert_equal(root, File.dirname(regular_file, regular_file.count('/')))
|
||||
assert_equal(root, File.dirname(regular_file, regular_file.count('/') + 100))
|
||||
end
|
||||
|
||||
def test_dirname_encoding
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue