From d7e0172e2df322d4d963c1b0571c8514b37950d3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 6 May 2010 20:50:32 -0700 Subject: [PATCH] `vagrant destroy` always forces the shutdown (does not attempt graceful) --- lib/vagrant/actions/vm/down.rb | 4 +++- test/vagrant/actions/vm/down_test.rb | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/actions/vm/down.rb b/lib/vagrant/actions/vm/down.rb index f8de682cf..1b6457746 100644 --- a/lib/vagrant/actions/vm/down.rb +++ b/lib/vagrant/actions/vm/down.rb @@ -3,7 +3,9 @@ module Vagrant module VM class Down < Base 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) end diff --git a/test/vagrant/actions/vm/down_test.rb b/test/vagrant/actions/vm/down_test.rb index 1795addb9..d59d3b335 100644 --- a/test/vagrant/actions/vm/down_test.rb +++ b/test/vagrant/actions/vm/down_test.rb @@ -13,7 +13,8 @@ class DownActionTest < Test::Unit::TestCase def setup_action_expectations(order) default_seq = sequence("default_seq") 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 @@ -24,7 +25,7 @@ class DownActionTest < Test::Unit::TestCase should "add the halt action if the VM is running" do @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 end end