From a13f587bc0d433fd58afbf2d1aecf6796914f6e5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 1 Sep 2010 14:37:37 -0700 Subject: [PATCH] Environment#error! removed (along with error? and so on) --- lib/vagrant/action.rb | 2 +- lib/vagrant/action/environment.rb | 22 ++++++-------------- test/vagrant/action/box/verify_test.rb | 5 +++-- test/vagrant/action/environment_test.rb | 16 +------------- test/vagrant/action/general/package_test.rb | 6 +++--- test/vagrant/action/vm/boot_test.rb | 2 +- test/vagrant/action/vm/check_box_test.rb | 5 +++-- test/vagrant/action/vm/forward_ports_test.rb | 12 +++++------ test/vagrant/action/vm/persist_test.rb | 3 +-- 9 files changed, 25 insertions(+), 48 deletions(-) diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 2c3f47c74..a4e7373a1 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -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 diff --git a/lib/vagrant/action/environment.rb b/lib/vagrant/action/environment.rb index 2111e0d03..d10ce2152 100644 --- a/lib/vagrant/action/environment.rb +++ b/lib/vagrant/action/environment.rb @@ -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 #----------------------------------------------------------------- diff --git a/test/vagrant/action/box/verify_test.rb b/test/vagrant/action/box/verify_test.rb index e12441aea..6b7a4bd94 100644 --- a/test/vagrant/action/box/verify_test.rb +++ b/test/vagrant/action/box/verify_test.rb @@ -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) - @instance.call(@env) - assert !@env.error? + assert_nothing_raised { + @instance.call(@env) + } end should "halt chain if verification fails" do diff --git a/test/vagrant/action/environment_test.rb b/test/vagrant/action/environment_test.rb index a89c2196e..eb21ec665 100644 --- a/test/vagrant/action/environment_test.rb +++ b/test/vagrant/action/environment_test.rb @@ -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 diff --git a/test/vagrant/action/general/package_test.rb b/test/vagrant/action/general/package_test.rb index fe8424aab..1ca225d2f 100644 --- a/test/vagrant/action/general/package_test.rb +++ b/test/vagrant/action/general/package_test.rb @@ -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 @instance.verify_included_files - assert !@env.error? + assert_nothing_raised { + assert @instance.verify_included_files + } end end diff --git a/test/vagrant/action/vm/boot_test.rb b/test/vagrant/action/vm/boot_test.rb index 8a7baf0b7..6fbb0e30b 100644 --- a/test/vagrant/action/vm/boot_test.rb +++ b/test/vagrant/action/vm/boot_test.rb @@ -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 diff --git a/test/vagrant/action/vm/check_box_test.rb b/test/vagrant/action/vm/check_box_test.rb index 00bdc3ffa..3cc1917ef 100644 --- a/test/vagrant/action/vm/check_box_test.rb +++ b/test/vagrant/action/vm/check_box_test.rb @@ -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) - @instance.call(@env) - assert !@env.error? + assert_nothing_raised { + @instance.call(@env) + } end end end diff --git a/test/vagrant/action/vm/forward_ports_test.rb b/test/vagrant/action/vm/forward_ports_test.rb index 2d74238fa..4fe4ceb4a 100644 --- a/test/vagrant/action/vm/forward_ports_test.rb +++ b/test/vagrant/action/vm/forward_ports_test.rb @@ -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) - @klass.new(@app, @env) - assert !@env.error? + + assert_nothing_raised { + @klass.new(@app, @env) + } 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 diff --git a/test/vagrant/action/vm/persist_test.rb b/test/vagrant/action/vm/persist_test.rb index 2c5196cc3..203154af7 100644 --- a/test/vagrant/action/vm/persist_test.rb +++ b/test/vagrant/action/vm/persist_test.rb @@ -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