From 6337cefb8becceed457234dabbf9859225d2e26f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 12 Oct 2010 20:57:04 -0700 Subject: [PATCH] Disable Vagrantfile validation completely on load. see coming commits... --- lib/vagrant/config.rb | 10 +++------- lib/vagrant/environment.rb | 2 +- test/vagrant/config_test.rb | 35 +---------------------------------- 3 files changed, 5 insertions(+), 42 deletions(-) diff --git a/lib/vagrant/config.rb b/lib/vagrant/config.rb index 1fb3b6835..5fd38185b 100644 --- a/lib/vagrant/config.rb +++ b/lib/vagrant/config.rb @@ -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 diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index be88cce3e..223aa434d 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -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 diff --git a/test/vagrant/config_test.rb b/test/vagrant/config_test.rb index f2f3f04dc..a5372d98a 100644 --- a/test/vagrant/config_test.rb +++ b/test/vagrant/config_test.rb @@ -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!