diff --git a/lib/vagrant/action/vm/boot.rb b/lib/vagrant/action/vm/boot.rb index 40d1cc2f9..861a86d6a 100644 --- a/lib/vagrant/action/vm/boot.rb +++ b/lib/vagrant/action/vm/boot.rb @@ -16,6 +16,7 @@ module Vagrant # Start up the VM and wait for it to boot. boot return env.error!(:vm_failed_to_boot) if !wait_for_boot + return if env.error? @app.call(env) end @@ -36,6 +37,10 @@ module Vagrant return true end + # Return true so that the vm_failed_to_boot error doesn't + # get shown + return true if @env.interrupted? + sleep sleeptime end diff --git a/test/vagrant/action/vm/boot_test.rb b/test/vagrant/action/vm/boot_test.rb index 89e7db184..aaf935a18 100644 --- a/test/vagrant/action/vm/boot_test.rb +++ b/test/vagrant/action/vm/boot_test.rb @@ -39,6 +39,17 @@ class BootVMActionTest < Test::Unit::TestCase @app.expects(:call).never @instance.call(@env) end + + should "not continue chain if error occured" do + boot_seq = sequence("boot_seq") + @instance.expects(:boot).in_sequence(boot_seq) + @instance.expects(:wait_for_boot).returns(true).in_sequence(boot_seq).with() do + @env.error!(:interrupt) + true + end + @app.expects(:call).never + @instance.call(@env) + end end context "booting" do @@ -58,6 +69,12 @@ class BootVMActionTest < Test::Unit::TestCase assert @instance.wait_for_boot(0) end + should "return right away if interrupted" do + @env.error!(:interrupt) + @vm.ssh.expects(:up?).times(1).returns(false) + assert @instance.wait_for_boot(0) + end + should "ping the max number of times then just return" do @vm.ssh.expects(:up?).times(@env.env.config.ssh.max_tries.to_i).returns(false) assert !@instance.wait_for_boot(0)