# typed: strict # frozen_string_literal: true module Minitest module Distributed module Reporters class DistributedSummaryReporter < Minitest::Reporter extend T::Sig sig { returns(Coordinators::CoordinatorInterface) } attr_reader :coordinator sig { params(io: IO, options: T::Hash[Symbol, T.untyped]).void } def initialize(io, options) super io.sync = true @coordinator = T.let(options[:distributed].coordinator, Coordinators::CoordinatorInterface) @start_time = T.let(0.0, Float) end sig { override.void } def start @start_time = Minitest.clock_time io.puts("Run options: #{options[:args]}\n\n") end sig { override.void } def report duration = format("(in %0.3fs)", Minitest.clock_time - @start_time) local_results = coordinator.local_results combined_results = coordinator.combined_results if combined_results == local_results io.puts("Results: #{combined_results} #{duration}") else io.puts("This worker: #{local_results} #{duration}") io.puts("Combined results: #{combined_results}") end end sig { override.returns(T::Boolean) } def passed? coordinator.combined_results.passed? end end end end end