From 461805851961ac3ebe733cadffaaf4d6363baa59 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 10 Mar 2023 09:22:01 +0100 Subject: [PATCH] Exit early if worker or build id is missing Avoid failing later down the stack with weird Redis errors. --- ruby/lib/minitest/queue/runner.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ruby/lib/minitest/queue/runner.rb b/ruby/lib/minitest/queue/runner.rb index e812abee..6c3b88f1 100644 --- a/ruby/lib/minitest/queue/runner.rb +++ b/ruby/lib/minitest/queue/runner.rb @@ -42,11 +42,13 @@ def run! end def retry_command + require_worker_id! STDERR.puts "Warning: the retry subcommand is deprecated." run_command # aliased for backward compatibility purpose end def run_command + require_worker_id! if queue.retrying? || retry? if queue.expired? abort! "The test run is too old and can't be retried" @@ -90,6 +92,7 @@ def run_command end def release_command + require_worker_id! queue.release! end @@ -249,6 +252,11 @@ def report_grind_command attr_reader :queue_config, :options, :command, :argv attr_accessor :queue, :queue_url, :grind_list, :grind_count, :load_paths + def require_worker_id! + invalid_usage!("build-id couldn't be inferred from ENV and wasn't set via --build") unless queue_config.build_id + invalid_usage!("worker-id couldn't be inferred from ENV and wasn't set via --worker") unless queue_config.worker_id + end + def display_warnings(build) build.pop_warnings.each do |type, attributes| case type