`vagrant destroy` always forces the shutdown (does not attempt graceful)

This commit is contained in:
Mitchell Hashimoto 2010-05-06 20:50:32 -07:00
parent 4d042da99b
commit d7e0172e2d
2 changed files with 6 additions and 3 deletions

View File

@ -3,7 +3,9 @@ module Vagrant
module VM module VM
class Down < Base class Down < Base
def prepare def prepare
@runner.add_action(Halt) if @runner.vm.running? # The true as the 2nd parameter always forces the shutdown so its
# fast (since we're destroying anyways)
@runner.add_action(Halt, true) if @runner.vm.running?
@runner.add_action(Destroy) @runner.add_action(Destroy)
end end

View File

@ -13,7 +13,8 @@ class DownActionTest < Test::Unit::TestCase
def setup_action_expectations(order) def setup_action_expectations(order)
default_seq = sequence("default_seq") default_seq = sequence("default_seq")
order.each do |action| order.each do |action|
@runner.expects(:add_action).with(action).once.in_sequence(default_seq) action = [action] unless action.is_a?(Array)
@runner.expects(:add_action).with(action.shift, *action).once.in_sequence(default_seq)
end end
end end
@ -24,7 +25,7 @@ class DownActionTest < Test::Unit::TestCase
should "add the halt action if the VM is running" do should "add the halt action if the VM is running" do
@vm.expects(:running?).returns(true) @vm.expects(:running?).returns(true)
setup_action_expectations([Vagrant::Actions::VM::Halt, Vagrant::Actions::VM::Destroy]) setup_action_expectations([[Vagrant::Actions::VM::Halt, true], Vagrant::Actions::VM::Destroy])
@action.prepare @action.prepare
end end
end end