Skip to content

Commit 714a180

Browse files
committed
Fixed bug: Task raises previous exception on second invokation after beeing reenable-d.
1 parent 124a03b commit 714a180

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

lib/rake/task.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def arg_names
141141
# Reenable the task, allowing its tasks to be executed if the task
142142
# is invoked again.
143143
def reenable
144-
@already_invoked = false
144+
@already_invoked = false
145+
@invocation_exception = nil
145146
end
146147

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

test/test_rake_task.rb

Lines changed: 27 additions & 0 deletions
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)