From f048c496d8a62691fb7fe97f459fe2eff7a0c3b7 Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Wed, 3 Jan 2024 14:38:40 +0000 Subject: [PATCH] Fix early returns --- ruby/lib/minitest/queue.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ruby/lib/minitest/queue.rb b/ruby/lib/minitest/queue.rb index dde1278e..0c258767 100644 --- a/ruby/lib/minitest/queue.rb +++ b/ruby/lib/minitest/queue.rb @@ -244,18 +244,19 @@ def run_from_queue(reporter, *) queue.report_success! end - requeued = false + acknowledged = false if failed && CI::Queue.requeueable?(result) && queue.requeue(example) - requeued = true result.requeue! reporter.record(result) - elsif queue.acknowledge(example) || !failed + elsif (acknowledged = queue.acknowledge(example)) || !failed # If the test was already acknowledged by another worker (we timed out) # Then we only record it if it is successful. reporter.record(result) end - if !requeued && failed + # If the test failed and we acknowledged it, we know it's a terminal failure and + # we have to record it for our circuit breaker. + if failed && acknowledged queue.increment_test_failed end end