Sha256: 199e91bee98beabac42bb99e497166de766e3ef1edee92959fadd3b9a58f18a7

Contents?: true

Size: 1.75 KB

Versions: 12

Compression:

Stored size: 1.75 KB

Contents

# typed: strict
# frozen_string_literal: true

module Minitest
  module Distributed
    module Reporters
      class RedisCoordinatorWarningsReporter < Minitest::Reporter
        extend T::Sig

        sig { override.void }
        def report
          warnings = [reclaim_timeout_warning, reclaim_failed_warning].compact
          warnings.each do |warning|
            io.puts(warning)
            io.puts
          end
        end

        private

        sig { returns(Configuration) }
        def configuration
          options[:distributed]
        end

        sig { returns(Coordinators::RedisCoordinator) }
        def redis_coordinator
          T.cast(configuration.coordinator, Coordinators::RedisCoordinator)
        end

        sig { returns(T.nilable(String)) }
        def reclaim_timeout_warning
          if redis_coordinator.reclaimed_timeout_tests.any?
            <<~WARNING
              WARNING: The following tests were reclaimed from another worker:
              #{redis_coordinator.reclaimed_timeout_tests.map { |test| "- #{test.identifier}" }.join("\n")}

              The original worker did not complete running these tests in #{configuration.test_timeout_seconds}s.
              This either means that the worker unexpectedly went away, or that the test is too slow.
            WARNING
          end
        end

        sig { returns(T.nilable(String)) }
        def reclaim_failed_warning
          if redis_coordinator.reclaimed_failed_tests.any?
            <<~WARNING
              WARNING: The following tests were reclaimed from another worker because they failed:
              #{redis_coordinator.reclaimed_failed_tests.map { |test| "- #{test.identifier}" }.join("\n")}
            WARNING
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
minitest-distributed-0.2.11 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.10 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.9 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.8 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.7 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.6 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.5 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.2 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.4 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.3 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.1 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb
minitest-distributed-0.2.0 lib/minitest/distributed/reporters/redis_coordinator_warnings_reporter.rb