Fix some small issues with up, down, and halt with the latest refactor.
This commit is contained in:
parent
455a44cc5d
commit
6f287aa17a
|
@ -5,7 +5,7 @@ module Vagrant
|
|||
def prepare
|
||||
# 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(Halt, :force => true) if @runner.vm.running?
|
||||
@runner.add_action(Destroy)
|
||||
end
|
||||
|
||||
|
|
|
@ -14,6 +14,10 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def force?
|
||||
!!options[:force]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,13 +8,18 @@ module Vagrant
|
|||
steps = [Boot]
|
||||
if !@runner.vm || !@runner.vm.saved?
|
||||
steps.unshift([Customize, ForwardPorts, SharedFolders])
|
||||
steps << Provision if !@runner.env.config.vm.provisioner.nil? && options[:provision]
|
||||
steps << Provision if provision?
|
||||
end
|
||||
|
||||
steps.flatten.each do |action_klass|
|
||||
@runner.add_action(action_klass, options)
|
||||
end
|
||||
end
|
||||
|
||||
def provision?
|
||||
enabled = options[:provision].nil? ? true : options[:provision]
|
||||
!@runner.env.config.vm.provisioner.nil? && enabled
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,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, true], Vagrant::Actions::VM::Destroy])
|
||||
setup_action_expectations([[Vagrant::Actions::VM::Halt, {:force => true}], Vagrant::Actions::VM::Destroy])
|
||||
@action.prepare
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,18 @@ class HaltActionTest < Test::Unit::TestCase
|
|||
@runner.stubs(:system).returns(linux_system(@vm))
|
||||
end
|
||||
|
||||
context "force?" do
|
||||
should "not force by default" do
|
||||
@action.options[:force] = nil
|
||||
assert !@action.force?
|
||||
end
|
||||
|
||||
should "force if specified" do
|
||||
@action.options[:force] = true
|
||||
assert @action.force?
|
||||
end
|
||||
end
|
||||
|
||||
context "executing" do
|
||||
setup do
|
||||
@vm.stubs(:running?).returns(true)
|
||||
|
|
|
@ -52,4 +52,22 @@ class StartActionTest < Test::Unit::TestCase
|
|||
@action.prepare
|
||||
end
|
||||
end
|
||||
|
||||
context "provision?" do
|
||||
should "return false if no provisioner is set" do
|
||||
@vm.env.config.vm.provisioner = nil
|
||||
assert !@action.provision?
|
||||
end
|
||||
|
||||
should "return true if a provisioner is set" do
|
||||
@vm.env.config.vm.provisioner = :chef_solo
|
||||
assert @action.provision?
|
||||
end
|
||||
|
||||
should "return false if provisioning is specifically disabled" do
|
||||
@vm.env.config.vm.provisioner = :chef_solo
|
||||
@action.options[:provision] = false
|
||||
assert !@action.provision?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue