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