MultiStep does not allow composing steps that do not work together
This commit is contained in:
parent
73761dc92a
commit
822226cae4
|
@ -78,10 +78,22 @@ module Vagrant
|
|||
maps[direct] = direct.variable
|
||||
end
|
||||
|
||||
# Take the missing inputs and map them together. For example
|
||||
# the input of ':a' maps directly to the previous output of ':a'
|
||||
(step_class.inputs - maps.values).each do |input|
|
||||
maps[input] = input
|
||||
end
|
||||
|
||||
# Turn the pure symbols into mapping from last steps
|
||||
maps.keys.each do |from|
|
||||
if from.kind_of?(Symbol)
|
||||
new_from = nil
|
||||
if @step_names.last.nil?
|
||||
new_from = input(from)
|
||||
else
|
||||
new_from = output(@step_names.last, from)
|
||||
end
|
||||
|
||||
maps[new_from] = maps.delete(from)
|
||||
end
|
||||
end
|
||||
|
@ -122,10 +134,6 @@ module Vagrant
|
|||
elsif from.kind_of?(StepOutput)
|
||||
# Step outputs get their data from a previous step's output.
|
||||
inputs[to] = step_outputs[from.name][from.variable]
|
||||
else
|
||||
# A basic remapping remaps the previous steps outputs to an
|
||||
# input for this step.
|
||||
inputs[to] = inputs.delete(from)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -137,6 +137,20 @@ describe Vagrant::Action::MultiStep do
|
|||
expect { g.step :foo }.to raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "should not allow a step that doesn't have all inputs satisfied" do
|
||||
step_A = Class.new(Vagrant::Action::Step) do
|
||||
output :output_A
|
||||
end
|
||||
|
||||
step_B = Class.new(Vagrant::Action::Step) do
|
||||
input :input_B
|
||||
end
|
||||
|
||||
g = described_class.new
|
||||
g.step step_A
|
||||
expect { g.step step_B }.to raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "should not allow remapping from outputs that don't exist" do
|
||||
step_A = Class.new(Vagrant::Action::Step) do
|
||||
output :output_A
|
||||
|
|
Loading…
Reference in New Issue