From b4aa8e60c3c7b7131976e0916f0a559f0e9353cf Mon Sep 17 00:00:00 2001 From: Luke Baker Date: Mon, 7 Oct 2013 11:41:33 -0400 Subject: [PATCH] retry failed tests once to verify failure --- lib/tasks/test_api.rake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/tasks/test_api.rake b/lib/tasks/test_api.rake index ea84a3b..8e2e0fc 100644 --- a/lib/tasks/test_api.rake +++ b/lib/tasks/test_api.rake @@ -100,6 +100,7 @@ namespace :test_api do desc "Description here" task(:question_vote_consistency => :environment) do + first_run_errors = [] errors = [] successes = [] @@ -111,7 +112,7 @@ namespace :test_api do message, error_occurred = send(taskname, question) debug("Completed task #{taskname} for question #{question.id}") if error_occurred - errors << message + first_run_errors << [taskname, question] else successes << message end @@ -122,7 +123,7 @@ namespace :test_api do @choice_tasks.each do |taskname, description| message, error_occurred = send(taskname, choice) if error_occurred - errors << message + first_run_errors << [taskname, choice] else successes << message end @@ -132,6 +133,18 @@ namespace :test_api do end + # retry the failed tasks in case they failed due to + # votes happening while the test was running. + debug("Re-running tasks that previously failed") + first_run_errors.each do |err| + message, error_occurred = send(err[0], err[1].reload) + if error_occurred + errors << message + else + successes << message + end + end + @global_tasks.each do |taskname, description| debug("Starting global task #{taskname}") message, error_occurred = send(taskname) -- libgit2 0.21.2