Skip to content
Permalink
Browse files

Merge pull request #271 from thorsteneckel/bugfix-reenable_invocation…

…_exception

Fixed bug: Reenabled task raises previous exception on second invokation
  • Loading branch information
hsbt committed Nov 12, 2019
2 parents 985abff + 282b0d3 commit b6e2a66689e7ac2f39597283dc2276bd082fa279
Showing with 28 additions and 0 deletions.
  1. +1 −0 lib/rake/task.rb
  2. +27 −0 test/test_rake_task.rb
@@ -146,6 +146,7 @@ def arg_names
# is invoked again.
def reenable
@already_invoked = false
@invocation_exception = nil
end

# Clear the existing prerequisites, actions, comments, and arguments of a rake task.
@@ -117,6 +117,33 @@ def test_can_double_invoke_with_reenable
assert_equal ["t1", "t1"], runlist
end

def test_can_triple_invoke_after_exception_with_reenable
raise_exception = true
invoked = 0

t1 = task(:t1) do |t|
invoked += 1
next if !raise_exception

raise_exception = false
raise 'Some error'
end

assert_raises(RuntimeError) { t1.invoke }
assert_equal 1, invoked

t1.reenable

# actually invoke second time
t1.invoke
assert_equal 2, invoked

# recognize already invoked and
# don't raise pre-reenable exception
t1.invoke
assert_equal 2, invoked
end

def test_clear
desc "a task"
t = task("t", ["b"] => "a") {}

0 comments on commit b6e2a66

Please sign in to comment.
You can’t perform that action at this time.