windows root path fix
This commit is contained in:
parent
dda15e9859
commit
b92efdfe53
|
@ -114,12 +114,10 @@ msg
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_root_path!(path=nil)
|
def load_root_path!(path=nil)
|
||||||
path ||= Pathname.new(Dir.pwd)
|
path = Pathname.new(File.expand_path(path || Dir.pwd))
|
||||||
|
|
||||||
# Stop if we're at the root. 2nd regex matches windows drives
|
# Stop if we're at the root.
|
||||||
# such as C:. and Z:. Portability of this check will need to be
|
return false if path.root?
|
||||||
# researched.
|
|
||||||
return false if path.to_s == '/' || path.to_s =~ /^[A-Z]:\.$/
|
|
||||||
|
|
||||||
file = "#{path}/#{ROOTFILE_NAME}"
|
file = "#{path}/#{ROOTFILE_NAME}"
|
||||||
if File.exist?(file)
|
if File.exist?(file)
|
||||||
|
|
|
@ -211,7 +211,7 @@ class EnvTest < Test::Unit::TestCase
|
||||||
context "loading the root path" do
|
context "loading the root path" do
|
||||||
should "default the path to the pwd if nil" do
|
should "default the path to the pwd if nil" do
|
||||||
@path = mock("path")
|
@path = mock("path")
|
||||||
@path.stubs(:to_s).returns("/")
|
@path.stubs(:root?).returns(true)
|
||||||
Pathname.expects(:new).with(Dir.pwd).returns(@path)
|
Pathname.expects(:new).with(Dir.pwd).returns(@path)
|
||||||
Vagrant::Env.load_root_path!(nil)
|
Vagrant::Env.load_root_path!(nil)
|
||||||
end
|
end
|
||||||
|
@ -219,7 +219,9 @@ class EnvTest < Test::Unit::TestCase
|
||||||
should "not default the path to pwd if its not nil" do
|
should "not default the path to pwd if its not nil" do
|
||||||
@path = mock("path")
|
@path = mock("path")
|
||||||
@path.stubs(:to_s).returns("/")
|
@path.stubs(:to_s).returns("/")
|
||||||
Pathname.expects(:new).never
|
File.expects(:expand_path).with(@path).returns("/")
|
||||||
|
Pathname.expects(:new).with("/").returns(@path)
|
||||||
|
@path.stubs(:root?).returns(true)
|
||||||
Vagrant::Env.load_root_path!(@path)
|
Vagrant::Env.load_root_path!(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -244,7 +246,8 @@ class EnvTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return false if not found on windows-style root" do
|
should "return false if not found on windows-style root" do
|
||||||
path = Pathname.new("C:.")
|
# Note the escaped back slash
|
||||||
|
path = Pathname.new("C:\\")
|
||||||
assert !Vagrant::Env.load_root_path!(path)
|
assert !Vagrant::Env.load_root_path!(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue