From 714a18093b38661508737a6849fc7168f28829a1 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 20 Aug 2018 14:50:48 +0200 Subject: [PATCH 1/2] Fixed bug: Task raises previous exception on second invokation after beeing reenable-d. --- lib/rake/task.rb | 3 ++- test/test_rake_task.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/rake/task.rb b/lib/rake/task.rb index c56118f01..5f5254c84 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -141,7 +141,8 @@ def arg_names # Reenable the task, allowing its tasks to be executed if the task # is invoked again. def reenable - @already_invoked = false + @already_invoked = false + @invocation_exception = nil end # Clear the existing prerequisites, actions, comments, and arguments of a rake task. diff --git a/test/test_rake_task.rb b/test/test_rake_task.rb index 380f59b4f..dca594329 100644 --- a/test/test_rake_task.rb +++ b/test/test_rake_task.rb @@ -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") {} From 282b0d31586c7b723f6ba7d5103f874adec1bdb9 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 22 Aug 2018 09:04:08 +0200 Subject: [PATCH 2/2] Applied requested changes of @yuki24: Chose clean git blame over nice looking indentaiton. --- lib/rake/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake/task.rb b/lib/rake/task.rb index 5f5254c84..2255b5c43 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -141,7 +141,7 @@ def arg_names # Reenable the task, allowing its tasks to be executed if the task # is invoked again. def reenable - @already_invoked = false + @already_invoked = false @invocation_exception = nil end