Environment#error! removed (along with error? and so on)

This commit is contained in:
Mitchell Hashimoto 2010-09-01 14:37:37 -07:00
parent 3da94252b5
commit a13f587bc0
9 changed files with 25 additions and 48 deletions

View File

@ -61,7 +61,7 @@ module Vagrant
end
env.ui.info "Waiting for cleanup before exiting..." if !@@reported_interrupt
action_environment.error!(:interrupt)
action_environment.interrupt!
@@reported_interrupt = true
end

View File

@ -26,7 +26,7 @@ module Vagrant
end
@env = env
@error = nil
@interrupted = false
end
# Returns a logger associated with the environment.
@ -39,26 +39,16 @@ module Vagrant
env.ui
end
# Flags the environment as erroneous. Stores the given key
# and options until the end of the action sequence.
#
# @param [Symbol] key Key to translation to display error message.
# @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?
# Marks an environment as interrupted (by an outside signal or
# anything)
def interrupt!
@interrupted = true
end
# Returns a boolean denoting if environment has been interrupted
# with a SIGINT.
def interrupted?
error? && error.first == :interrupt
!!@interrupted
end
#-----------------------------------------------------------------

View File

@ -20,8 +20,9 @@ class VerifyBoxActionTest < Test::Unit::TestCase
seq = sequence("seq")
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file).in_sequence(seq)
@app.expects(:call).with(@env).once.in_sequence(seq)
assert_nothing_raised {
@instance.call(@env)
assert !@env.error?
}
end
should "halt chain if verification fails" do

View File

@ -19,23 +19,9 @@ class ActionEnvironmentTest < Test::Unit::TestCase
assert_equal @instance.env.ui, @instance.ui
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
assert !@instance.interrupted?
@instance.error!(:interrupt)
@instance.interrupt!
assert @instance.interrupted?
end

View File

@ -18,7 +18,6 @@ class PackageGeneralActionTest < Test::Unit::TestCase
should "initialize fine" do
@klass.new(@app, @env)
assert !@env.error?
end
should "set the output path to configured by default" do
@ -124,8 +123,9 @@ class PackageGeneralActionTest < Test::Unit::TestCase
end
should "return true if all exist" do
assert_nothing_raised {
assert @instance.verify_included_files
assert !@env.error?
}
end
end

View File

@ -53,7 +53,7 @@ class BootVMActionTest < Test::Unit::TestCase
end
should "return right away if interrupted" do
@env.error!(:interrupt)
@env.interrupt!
@vm.ssh.expects(:up?).times(1).returns(false)
assert @instance.wait_for_boot
end

View File

@ -39,8 +39,9 @@ class CheckBoxVMActionTest < Test::Unit::TestCase
@env.env.expects(:load_box!).in_sequence(seq)
@app.expects(:call).with(@env).once.in_sequence(seq)
assert_nothing_raised {
@instance.call(@env)
assert !@env.error?
}
end
end
end

View File

@ -35,8 +35,10 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
should "not error if ports are fine" do
@env.env.config.vm.forwarded_ports.clear
@env.env.config.vm.forward_port("foo", 22, 2222)
assert_nothing_raised {
@klass.new(@app, @env)
assert !@env.error?
}
end
end
@ -52,15 +54,13 @@ class ForwardPortsVMActionTest < Test::Unit::TestCase
should "not raise any errors if no forwarded ports collide" do
@used_ports << "80"
@klass.new(@app, @env)
assert !@env.error?
assert_nothing_raised { @klass.new(@app, @env) }
end
should "handle collision if it happens" do
@used_ports << "2222"
@klass.any_instance.expects(:handle_collision).with("ssh", anything, anything).once
@klass.new(@app, @env)
assert !@env.error?
assert_nothing_raised { @klass.new(@app, @env) }
end
end

View File

@ -27,8 +27,7 @@ class PersistVMActionTest < Test::Unit::TestCase
should "initialize properly if dotfiles doesn't exist" do
File.expects(:exist?).with(@env.env.dotfile_path).returns(false)
@klass.new(@app, @env)
assert !@env.error?
assert_nothing_raised { @klass.new(@app, @env) }
end
end