Skip to content

Commit b6e2a66

Browse files
authoredNov 12, 2019
Merge pull request #271 from thorsteneckel/bugfix-reenable_invocation_exception
Fixed bug: Reenabled task raises previous exception on second invokation
2 parents 985abff + 282b0d3 commit b6e2a66

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
 

‎lib/rake/task.rb

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def arg_names
146146
# is invoked again.
147147
def reenable
148148
@already_invoked = false
149+
@invocation_exception = nil
149150
end
150151

151152
# Clear the existing prerequisites, actions, comments, and arguments of a rake task.

‎test/test_rake_task.rb

+27
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,33 @@ def test_can_double_invoke_with_reenable
117117
assert_equal ["t1", "t1"], runlist
118118
end
119119

120+
def test_can_triple_invoke_after_exception_with_reenable
121+
raise_exception = true
122+
invoked = 0
123+
124+
t1 = task(:t1) do |t|
125+
invoked += 1
126+
next if !raise_exception
127+
128+
raise_exception = false
129+
raise 'Some error'
130+
end
131+
132+
assert_raises(RuntimeError) { t1.invoke }
133+
assert_equal 1, invoked
134+
135+
t1.reenable
136+
137+
# actually invoke second time
138+
t1.invoke
139+
assert_equal 2, invoked
140+
141+
# recognize already invoked and
142+
# don't raise pre-reenable exception
143+
t1.invoke
144+
assert_equal 2, invoked
145+
end
146+
120147
def test_clear
121148
desc "a task"
122149
t = task("t", ["b"] => "a") {}

0 commit comments

Comments
 (0)