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