Environment#error! removed (along with error? and so on)
This commit is contained in:
parent
3da94252b5
commit
a13f587bc0
|
@ -61,7 +61,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
env.ui.info "Waiting for cleanup before exiting..." if !@@reported_interrupt
|
env.ui.info "Waiting for cleanup before exiting..." if !@@reported_interrupt
|
||||||
action_environment.error!(:interrupt)
|
action_environment.interrupt!
|
||||||
@@reported_interrupt = true
|
@@reported_interrupt = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
@env = env
|
@env = env
|
||||||
@error = nil
|
@interrupted = false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a logger associated with the environment.
|
# Returns a logger associated with the environment.
|
||||||
|
@ -39,26 +39,16 @@ module Vagrant
|
||||||
env.ui
|
env.ui
|
||||||
end
|
end
|
||||||
|
|
||||||
# Flags the environment as erroneous. Stores the given key
|
# Marks an environment as interrupted (by an outside signal or
|
||||||
# and options until the end of the action sequence.
|
# anything)
|
||||||
#
|
def interrupt!
|
||||||
# @param [Symbol] key Key to translation to display error message.
|
@interrupted = true
|
||||||
# @param [Hash] options Variables to pass to the translation
|
|
||||||
def error!(key, options=nil)
|
|
||||||
@error = [key, (options || {})]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns boolean denoting if environment is in erroneous state.
|
|
||||||
#
|
|
||||||
# @return [Boolean]
|
|
||||||
def error?
|
|
||||||
!error.nil?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a boolean denoting if environment has been interrupted
|
# Returns a boolean denoting if environment has been interrupted
|
||||||
# with a SIGINT.
|
# with a SIGINT.
|
||||||
def interrupted?
|
def interrupted?
|
||||||
error? && error.first == :interrupt
|
!!@interrupted
|
||||||
end
|
end
|
||||||
|
|
||||||
#-----------------------------------------------------------------
|
#-----------------------------------------------------------------
|
||||||
|
|
|
@ -20,8 +20,9 @@ class VerifyBoxActionTest < Test::Unit::TestCase
|
||||||
seq = sequence("seq")
|
seq = sequence("seq")
|
||||||
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file).in_sequence(seq)
|
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file).in_sequence(seq)
|
||||||
@app.expects(:call).with(@env).once.in_sequence(seq)
|
@app.expects(:call).with(@env).once.in_sequence(seq)
|
||||||
@instance.call(@env)
|
assert_nothing_raised {
|
||||||
assert !@env.error?
|
@instance.call(@env)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
should "halt chain if verification fails" do
|
should "halt chain if verification fails" do
|
||||||
|
|
|
@ -19,23 +19,9 @@ class ActionEnvironmentTest < Test::Unit::TestCase
|
||||||
assert_equal @instance.env.ui, @instance.ui
|
assert_equal @instance.env.ui, @instance.ui
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not be erroneous initially" do
|
|
||||||
assert !@instance.error?
|
|
||||||
end
|
|
||||||
|
|
||||||
should "mark as erroneous" do
|
|
||||||
@instance.error!(:key)
|
|
||||||
assert_equal [:key, {}], @instance.error
|
|
||||||
end
|
|
||||||
|
|
||||||
should "properly report erroneous" do
|
|
||||||
@instance.error!(:key)
|
|
||||||
assert @instance.error?
|
|
||||||
end
|
|
||||||
|
|
||||||
should "report interrupted if interrupt error" do
|
should "report interrupted if interrupt error" do
|
||||||
assert !@instance.interrupted?
|
assert !@instance.interrupted?
|
||||||
@instance.error!(:interrupt)
|
@instance.interrupt!
|
||||||
assert @instance.interrupted?
|
assert @instance.interrupted?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ class PackageGeneralActionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
should "initialize fine" do
|
should "initialize fine" do
|
||||||
@klass.new(@app, @env)
|
@klass.new(@app, @env)
|
||||||
assert !@env.error?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "set the output path to configured by default" do
|
should "set the output path to configured by default" do
|
||||||
|
@ -124,8 +123,9 @@ class PackageGeneralActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return true if all exist" do
|
should "return true if all exist" do
|
||||||
assert @instance.verify_included_files
|
assert_nothing_raised {
|
||||||
assert !@env.error?
|
assert @instance.verify_included_files
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class BootVMActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return right away if interrupted" do
|
should "return right away if interrupted" do
|
||||||
@env.error!(:interrupt)
|
@env.interrupt!
|
||||||
@vm.ssh.expects(:up?).times(1).returns(false)
|
@vm.ssh.expects(:up?).times(1).returns(false)
|
||||||
assert @instance.wait_for_boot
|
assert @instance.wait_for_boot
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,8 +39,9 @@ class CheckBoxVMActionTest < Test::Unit::TestCase
|
||||||
@env.env.expects(:load_box!).in_sequence(seq)
|
@env.env.expects(:load_box!).in_sequence(seq)
|
||||||
@app.expects(:call).with(@env).once.in_sequence(seq)
|
@app.expects(:call).with(@env).once.in_sequence(seq)
|
||||||
|
|
||||||
@instance.call(@env)
|
assert_nothing_raised {
|
||||||
assert !@env.error?
|
@instance.call(@env)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,8 +35,10 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
|
||||||
should "not error if ports are fine" do
|
should "not error if ports are fine" do
|
||||||
@env.env.config.vm.forwarded_ports.clear
|
@env.env.config.vm.forwarded_ports.clear
|
||||||
@env.env.config.vm.forward_port("foo", 22, 2222)
|
@env.env.config.vm.forward_port("foo", 22, 2222)
|
||||||
@klass.new(@app, @env)
|
|
||||||
assert !@env.error?
|
assert_nothing_raised {
|
||||||
|
@klass.new(@app, @env)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,15 +54,13 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
should "not raise any errors if no forwarded ports collide" do
|
should "not raise any errors if no forwarded ports collide" do
|
||||||
@used_ports << "80"
|
@used_ports << "80"
|
||||||
@klass.new(@app, @env)
|
assert_nothing_raised { @klass.new(@app, @env) }
|
||||||
assert !@env.error?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
should "handle collision if it happens" do
|
should "handle collision if it happens" do
|
||||||
@used_ports << "2222"
|
@used_ports << "2222"
|
||||||
@klass.any_instance.expects(:handle_collision).with("ssh", anything, anything).once
|
@klass.any_instance.expects(:handle_collision).with("ssh", anything, anything).once
|
||||||
@klass.new(@app, @env)
|
assert_nothing_raised { @klass.new(@app, @env) }
|
||||||
assert !@env.error?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,7 @@ class PersistVMActionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
should "initialize properly if dotfiles doesn't exist" do
|
should "initialize properly if dotfiles doesn't exist" do
|
||||||
File.expects(:exist?).with(@env.env.dotfile_path).returns(false)
|
File.expects(:exist?).with(@env.env.dotfile_path).returns(false)
|
||||||
@klass.new(@app, @env)
|
assert_nothing_raised { @klass.new(@app, @env) }
|
||||||
assert !@env.error?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue