core: environment tests passing on Windows
This commit is contained in:
parent
7248797fa5
commit
e2ec46bb4d
|
@ -598,9 +598,8 @@ module Vagrant
|
|||
#
|
||||
# @return [Pathname]
|
||||
def setup_home_path
|
||||
@home_path = Pathname.new(File.expand_path(@home_path ||
|
||||
ENV["VAGRANT_HOME"] ||
|
||||
Vagrant.user_data_path))
|
||||
@home_path = Util::Platform.fs_real_path(
|
||||
@home_path || ENV["VAGRANT_HOME"] || Vagrant.user_data_path)
|
||||
@logger.info("Home path: #{@home_path}")
|
||||
|
||||
# Setup the list of child directories that need to be created if they
|
||||
|
|
|
@ -61,19 +61,7 @@ module Vagrant
|
|||
def fs_real_path(path)
|
||||
path = Pathname.new(File.expand_path(path))
|
||||
|
||||
if windows?
|
||||
# Fix the drive letter to be uppercase.
|
||||
path = path.to_s
|
||||
if path[1] == ":"
|
||||
path[0] = path[0].upcase
|
||||
end
|
||||
|
||||
path = Pathname.new(path)
|
||||
end
|
||||
|
||||
return path if !path.exist?
|
||||
return path if fs_case_sensitive?
|
||||
|
||||
if path.exist? && !fs_case_sensitive?
|
||||
# Build up all the parts of the path
|
||||
original = []
|
||||
while !path.root?
|
||||
|
@ -89,6 +77,17 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if windows?
|
||||
# Fix the drive letter to be uppercase.
|
||||
path = path.to_s
|
||||
if path[1] == ":"
|
||||
path[0] = path[0].upcase
|
||||
end
|
||||
|
||||
path = Pathname.new(path)
|
||||
end
|
||||
|
||||
path
|
||||
end
|
||||
|
|
|
@ -230,19 +230,15 @@ describe Vagrant::Environment do
|
|||
end
|
||||
|
||||
context "default home path" do
|
||||
before :each do
|
||||
Vagrant::Util::Platform.stub(:windows? => false)
|
||||
end
|
||||
|
||||
it "is set to '~/.vagrant.d' by default" do
|
||||
expected = Pathname.new(File.expand_path("~/.vagrant.d"))
|
||||
expected = Vagrant::Util::Platform.fs_real_path("~/.vagrant.d")
|
||||
described_class.new.home_path.should == expected
|
||||
end
|
||||
|
||||
it "is set to '~/.vagrant.d' if on Windows but no USERPROFILE" do
|
||||
Vagrant::Util::Platform.stub(:windows? => true)
|
||||
|
||||
expected = Pathname.new(File.expand_path("~/.vagrant.d"))
|
||||
expected = Vagrant::Util::Platform.fs_real_path("~/.vagrant.d")
|
||||
|
||||
with_temp_env("USERPROFILE" => nil) do
|
||||
described_class.new.home_path.should == expected
|
||||
|
@ -253,7 +249,7 @@ describe Vagrant::Environment do
|
|||
Vagrant::Util::Platform.stub(:windows? => true)
|
||||
|
||||
Dir.mktmpdir do |dir|
|
||||
expected = Pathname.new(File.expand_path("#{dir}/.vagrant.d"))
|
||||
expected = Vagrant::Util::Platform.fs_real_path("#{dir}/.vagrant.d")
|
||||
|
||||
with_temp_env("USERPROFILE" => dir) do
|
||||
described_class.new.home_path.should == expected
|
||||
|
|
Loading…
Reference in New Issue