Merge pull request #10220 from briancain/FIX-PATH-WARNING-WINDOWS

Ensure file paths are identical when checking for cwd
This commit is contained in:
Brian Cain 2018-09-19 09:01:09 -07:00 committed by GitHub
commit b580268730
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -593,7 +593,7 @@ module Vagrant
).chomp
end
if vagrant_cwd != @env.root_path.to_s
if !File.identical?(vagrant_cwd.to_s, @env.root_path.to_s)
if vagrant_cwd
ui.warn(I18n.t(
'vagrant.moved_cwd',

View File

@ -370,6 +370,26 @@ describe Vagrant::Machine do
end
end
it 'should not warn if dirs are same but different cases' do
action_name = :destroy
callable = lambda { |_env| }
original_cwd = env.cwd.to_s
allow(provider).to receive(:action).with(action_name).and_return(callable)
allow(subject.ui).to receive(:warn)
instance.action(action_name)
expect(subject.ui).to_not have_received(:warn)
# In cygwin or other windows shell, it might have a path like
# c:/path and C:/path
# which are the same.
allow(env).to receive(:root_path).and_return(original_cwd.upcase)
expect(subject.ui).to_not have_received(:warn)
instance.action(action_name)
end
context "if in a subdir" do
let (:data_dir) { env.cwd }