From 71101c9d3d37979f5615eb7178bc2faf069b83b9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 1 Sep 2010 14:58:22 -0700 Subject: [PATCH] Raise interrupt error earlier so the rescue chain actually gets called --- lib/vagrant/action/warden.rb | 3 +-- test/vagrant/action/warden_test.rb | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/vagrant/action/warden.rb b/lib/vagrant/action/warden.rb index 857c7d03d..ece79ddc2 100644 --- a/lib/vagrant/action/warden.rb +++ b/lib/vagrant/action/warden.rb @@ -21,6 +21,7 @@ module Vagrant # Call the next middleware in the sequence, appending to the stack # of "recoverable" middlewares in case something goes wrong! @stack.unshift(@actions.shift).first.call(env) + raise Errors::VagrantInterrupt.new if env.interrupted? rescue # Something went horribly wrong. Start the rescue chain then # reraise the exception to properly kick us out of limbo here. @@ -33,8 +34,6 @@ module Vagrant @stack.each do |act| act.recover(env) if act.respond_to?(:recover) end - - raise Errors::VagrantInterrupt.new if env.interrupted? end def finalize_action(action, env) diff --git a/test/vagrant/action/warden_test.rb b/test/vagrant/action/warden_test.rb index 94aa30a62..6e8015057 100644 --- a/test/vagrant/action/warden_test.rb +++ b/test/vagrant/action/warden_test.rb @@ -66,6 +66,16 @@ class ActionWardenTest < Test::Unit::TestCase @instance.expects(:begin_rescue) assert_raises(RuntimeError) { @instance.call(new_env) } end + + should "raise interrupt if the environment is interupted" do + env = new_env + env.expects(:interrupted?).returns(true) + @instance.actions << lambda { |env| } + + assert_raises(Vagrant::Errors::VagrantInterrupt) { + @instance.call(env) + } + end end context "recover" do @@ -78,20 +88,6 @@ class ActionWardenTest < Test::Unit::TestCase @instance.begin_rescue(new_env) end - - should "call exit if the environment is interupted" do - env = new_env - env.expects(:interrupted?).returns(true) - assert_raises(Vagrant::Errors::VagrantInterrupt) { - @instance.begin_rescue(env) - } - end - - context "with many middleware" do - should "not call middleware after" do - - end - end end def new_env