Raise an error if the CWD is incorrect
This commit is contained in:
parent
6969f791ad
commit
f8fa859b5f
|
@ -59,6 +59,7 @@ module Vagrant
|
||||||
opts[:cwd] ||= ENV["VAGRANT_CWD"] if ENV.has_key?("VAGRANT_CWD")
|
opts[:cwd] ||= ENV["VAGRANT_CWD"] if ENV.has_key?("VAGRANT_CWD")
|
||||||
opts[:cwd] ||= Dir.pwd
|
opts[:cwd] ||= Dir.pwd
|
||||||
opts[:cwd] = Pathname.new(opts[:cwd])
|
opts[:cwd] = Pathname.new(opts[:cwd])
|
||||||
|
raise Errors::EnvironmentNonExistentCWD if !opts[:cwd].directory?
|
||||||
|
|
||||||
# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
|
# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
|
||||||
# those continue to work as well, but anything custom will take precedence.
|
# those continue to work as well, but anything custom will take precedence.
|
||||||
|
|
|
@ -173,6 +173,11 @@ module Vagrant
|
||||||
error_key(:status_error, "vagrant.downloaders.http")
|
error_key(:status_error, "vagrant.downloaders.http")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class EnvironmentNonExistentCWD < VagrantError
|
||||||
|
status_code(75)
|
||||||
|
error_key(:environment_non_existent_cwd)
|
||||||
|
end
|
||||||
|
|
||||||
class EnvironmentLockedError < VagrantError
|
class EnvironmentLockedError < VagrantError
|
||||||
status_code(52)
|
status_code(52)
|
||||||
error_key(:environment_locked)
|
error_key(:environment_locked)
|
||||||
|
|
|
@ -17,13 +17,19 @@ describe Vagrant::Environment do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is set to the cwd given" do
|
it "is set to the cwd given" do
|
||||||
instance = described_class.new(:cwd => "foobarbaz")
|
directory = File.dirname(__FILE__)
|
||||||
instance.cwd.should == Pathname.new("foobarbaz")
|
instance = described_class.new(:cwd => directory)
|
||||||
|
instance.cwd.should == Pathname.new(directory)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is set to the environmental variable VAGRANT_CWD" do
|
it "is set to the environmental variable VAGRANT_CWD" do
|
||||||
pending "A good temporary ENV thing"
|
pending "A good temporary ENV thing"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "raises an exception if the CWD doesn't exist" do
|
||||||
|
expect { described_class.new(:cwd => "doesntexist") }.
|
||||||
|
to raise_error(Vagrant::Errors::EnvironmentNonExistentCWD)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "home path" do
|
describe "home path" do
|
||||||
|
|
Loading…
Reference in New Issue