Disable Vagrantfile validation completely on load. see coming commits...

This commit is contained in:
Mitchell Hashimoto 2010-10-12 20:57:04 -07:00
parent ed5df8d90d
commit 6337cefb8b
3 changed files with 5 additions and 42 deletions

View File

@ -68,13 +68,9 @@ module Vagrant
# and returns the final configured object. This also validates the
# configuration by calling {Top#validate!} on every configuration
# class.
def execute!(validate=true)
def execute!
config_object ||= config
run_procs!(config_object)
# Validate if we're looking at a config object which represents a
# real VM.
config_object.validate! if validate && config_object.env.vm
config_object
end
end
@ -90,7 +86,7 @@ module Vagrant
# Loads the queue of files/procs, executes them in the proper
# sequence, and returns the resulting configuration object.
def load!(validate=true)
def load!
self.class.reset!(@env)
queue.flatten.each do |item|
@ -106,7 +102,7 @@ module Vagrant
end
end
return self.class.execute!(validate)
return self.class.execute!
end
end

View File

@ -313,7 +313,7 @@ module Vagrant
# Execute the configuration stack and store the result as the final
# value in the config ivar.
@config = loader.load!(!first_run)
@config = loader.load!
# (re)load the logger
@logger = nil

View File

@ -9,8 +9,6 @@ class ConfigTest < Test::Unit::TestCase
setup do
@env = vagrant_env
@instance = @klass.new(@env)
@klass::Top.any_instance.stubs(:validate!)
end
should "initially have an empty queue" do
@ -20,17 +18,10 @@ class ConfigTest < Test::Unit::TestCase
should "reset the config class on load, then execute" do
seq = sequence("sequence")
@klass.expects(:reset!).with(@env).in_sequence(seq)
@klass.expects(:execute!).with(true).in_sequence(seq)
@klass.expects(:execute!).in_sequence(seq)
@instance.load!
end
should "not validate if told not to" do
seq = sequence("sequence")
@klass.expects(:reset!).with(@env).in_sequence(seq)
@klass.expects(:execute!).with(false).in_sequence(seq)
@instance.load!(false)
end
should "run the queue in the order given" do
@instance.queue << Proc.new { |config| config.vm.box = "foo" }
@instance.queue << Proc.new { |config| config.vm.box = "bar" }
@ -113,7 +104,6 @@ class ConfigTest < Test::Unit::TestCase
context "initializing" do
setup do
@klass.reset!(vagrant_env)
@klass::Top.any_instance.stubs(:validate!)
end
should "add the given block to the proc stack" do
@ -122,29 +112,6 @@ class ConfigTest < Test::Unit::TestCase
assert_equal [proc], @klass.proc_stack
end
should "run the validation on an environment which represents a VM" do
@klass.reset!(vagrant_env.vms[:default].env)
seq = sequence('seq')
@klass.expects(:run_procs!).with(@klass.config).once.in_sequence(seq)
@klass.config.expects(:validate!).once.in_sequence(seq)
@klass.execute!
end
should "not run the validation on an environment that doesn't directly represent a VM" do
seq = sequence('seq')
@klass.expects(:run_procs!).with(@klass.config).once.in_sequence(seq)
@klass.expects(:validate!).never
@klass.execute!
end
should "not run the validation if explicitly told not to" do
@klass.reset!(vagrant_env.vms[:default].env)
seq = sequence('seq')
@klass.expects(:run_procs!).with(@klass.config).once.in_sequence(seq)
@klass.config.expects(:validate!).never
@klass.execute!(false)
end
should "return the configuration on execute!" do
@klass.run {}
result = @klass.execute!