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")
|
||||
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
|
||||
# of actions. If an exception is raised in any action in the current
|
||||
# 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
|
||||
# initialized, then call the execute! method
|
||||
begin
|
||||
[:prepare, :execute!].each do |method|
|
||||
[:prepare, :execute!, :cleanup].each do |method|
|
||||
actions.each do |action|
|
||||
action.send(method)
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ class ActionRunnerTest < Test::Unit::TestCase
|
|||
action = mock("action")
|
||||
action.stubs(:prepare)
|
||||
action.stubs(:execute!)
|
||||
action.stubs(:cleanup)
|
||||
action
|
||||
end
|
||||
|
||||
|
@ -120,7 +121,7 @@ class ActionRunnerTest < Test::Unit::TestCase
|
|||
run_class.expects(:new).once.returns(run_action)
|
||||
@runner.actions << action
|
||||
|
||||
[:prepare, :execute!].each do |method|
|
||||
[:prepare, :execute!, :cleanup].each do |method|
|
||||
action.expects(method).never
|
||||
run_action.expects(method).once
|
||||
end
|
||||
|
@ -146,7 +147,7 @@ class ActionRunnerTest < Test::Unit::TestCase
|
|||
actions << action
|
||||
end
|
||||
|
||||
[:prepare, :execute!].each do |method|
|
||||
[:prepare, :execute!, :cleanup].each do |method|
|
||||
actions.each do |action|
|
||||
action.expects(method).once.in_sequence(action_seq)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue