Actions can now implement the #cleanup method which is called after all other actions have finished executing.
This commit is contained in:
parent
dce3c032be
commit
e50e264747
|
@ -47,6 +47,11 @@ module Vagrant
|
||||||
# @vm.invoke_callback(:after_oven, "more", "than", "one", "option")
|
# @vm.invoke_callback(:after_oven, "more", "than", "one", "option")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This method is called after all actions have finished executing.
|
||||||
|
# It is meant as a place where final cleanup code can be done, knowing
|
||||||
|
# that all other actions are finished using your data.
|
||||||
|
def cleanup; end
|
||||||
|
|
||||||
# This method is only called if some exception occurs in the chain
|
# This method is only called if some exception occurs in the chain
|
||||||
# of actions. If an exception is raised in any action in the current
|
# of actions. If an exception is raised in any action in the current
|
||||||
# chain, then every action part of that chain has {#rescue} called
|
# chain, then every action part of that chain has {#rescue} called
|
||||||
|
|
|
@ -41,7 +41,7 @@ module Vagrant
|
||||||
# Call the prepare method on each once its
|
# Call the prepare method on each once its
|
||||||
# initialized, then call the execute! method
|
# initialized, then call the execute! method
|
||||||
begin
|
begin
|
||||||
[:prepare, :execute!].each do |method|
|
[:prepare, :execute!, :cleanup].each do |method|
|
||||||
actions.each do |action|
|
actions.each do |action|
|
||||||
action.send(method)
|
action.send(method)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ class ActionRunnerTest < Test::Unit::TestCase
|
||||||
action = mock("action")
|
action = mock("action")
|
||||||
action.stubs(:prepare)
|
action.stubs(:prepare)
|
||||||
action.stubs(:execute!)
|
action.stubs(:execute!)
|
||||||
|
action.stubs(:cleanup)
|
||||||
action
|
action
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ class ActionRunnerTest < Test::Unit::TestCase
|
||||||
run_class.expects(:new).once.returns(run_action)
|
run_class.expects(:new).once.returns(run_action)
|
||||||
@runner.actions << action
|
@runner.actions << action
|
||||||
|
|
||||||
[:prepare, :execute!].each do |method|
|
[:prepare, :execute!, :cleanup].each do |method|
|
||||||
action.expects(method).never
|
action.expects(method).never
|
||||||
run_action.expects(method).once
|
run_action.expects(method).once
|
||||||
end
|
end
|
||||||
|
@ -146,7 +147,7 @@ class ActionRunnerTest < Test::Unit::TestCase
|
||||||
actions << action
|
actions << action
|
||||||
end
|
end
|
||||||
|
|
||||||
[:prepare, :execute!].each do |method|
|
[:prepare, :execute!, :cleanup].each do |method|
|
||||||
actions.each do |action|
|
actions.each do |action|
|
||||||
action.expects(method).once.in_sequence(action_seq)
|
action.expects(method).once.in_sequence(action_seq)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue