Bug #1266
closedrelative_path broken on windows
Description
=begin
pwd = Pathname.new("C:/Development/src/ruby_trunk/test/minitest")
basedir = Pathname.new("c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/mini")
basedir.relative_path_from(pwd)
ArgumentError: different prefix: "c:/" and "C:/Development/src/ruby_trunk/test/minitest"
from c:/Development/ruby/lib/ruby/1.8/pathname.rb:709:in `relative_path_from'
This breaks running the ruby tests on windows.
=end
Files
Updated by cfis (Charlie Savage) over 15 years ago
- File pathname.patch pathname.patch added
=begin
I was hoping we could raise the priority of this issue. This bug prevents Ruby's test suite from being run at all on windows:
:\Development\src\ruby_trunk\test>ruby runner.rb minitest\test_mini_test.rb
c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/pathname.rb:790:in relative_path_from': different prefix: "c:/" and "C:/Development/src/ruby_trunk/test" (ArgumentError) from C:/Development/src/ruby_trunk/test/minitest/test_mini_test.rb:33:in
class:TestMiniTest'
from C:/Development/src/ruby_trunk/test/minitest/test_mini_test.rb:16:in <top (required)>' from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:55:in
require'
from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:55:in block in setup_argv' from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:49:in
each'
from c:/Development/ruby-1.9.1/usr/lib/ruby/1.9.1/test/unit.rb:49:in setup_argv' from runner.rb:9:in
'
The issues is that relative path is using case-sensitive comparisons. That's right on Linux, wrong on Windows. For whatever reason on Windows FILE returns c:.. while Dir.pwd returns C:.. And thus the problem.
I've attahced a proposed patch. If on windows (detecting mswin or mingw) then the comparison uses casecmp instead of ==. This seems like it would also apply on OS X when having a case-insensitive HFS+ drive.
=end
Updated by nobu (Nobuyoshi Nakada) over 15 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23093.
=end
Updated by cfis (Charlie Savage) over 15 years ago
=begin
Thanks Nobu - looks great. I didn't know about the File::FNM_SYSCASE constant.
=end