Can now ctrl-C during SSH attempts [closes GH-115]

This commit is contained in:
Mitchell Hashimoto 2010-07-21 21:38:01 -07:00
parent 4e8b6f32b4
commit d09ebe1021
2 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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)