Class: Minitest::Distributed::Reporters::DistributedSummaryReporter

Inherits:
Reporter
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/minitest/distributed/reporters/distributed_summary_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, options) ⇒ DistributedSummaryReporter

Returns a new instance of DistributedSummaryReporter.



11
12
13
14
15
# File 'lib/minitest/distributed/reporters/distributed_summary_reporter.rb', line 11

def initialize(io, options)
  super
  io.sync = true
  @start_time = T.let(0.0, Float)
end

Instance Method Details

#passed? ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
80
81
82
83
84
85
86
87
# File 'lib/minitest/distributed/reporters/distributed_summary_reporter.rb', line 77

def passed?
  return true if superseded?
  return false if configuration.coordinator.aborted?

  # Generally, we want the workers to fail that had at least one failed or errored
  # test. We have to trust that another worker will fail (and fail the build) if it
  # encountered a failed test. We trust that the other worker will do this correctly,
  # but we do verify that the statistics for the complete run are valid,
  # to have some protection against unknown edge cases and bugs.
  local_results.passed? && configuration.coordinator.valid_combined_results?
end

#report ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/minitest/distributed/reporters/distributed_summary_reporter.rb', line 24

def report
  print_discard_warning if local_results.discards > 0 && !current_attempt_truncated? && !superseded?

  if superseded?
    print_local_results("This worker was superseded; its local results do not affect the authoritative run.")
    return
  elsif registration_rejected?
    print_local_results("Combined results are unavailable because coordinator registration was rejected.")
    return
  elsif truncation_state_invalid?
    print_local_results("Combined results are unavailable because the retained truncation state is incomplete.")
    return
  elsif coordinator_stalled?
    print_local_results("Combined results are unavailable because the Redis coordinator state is invalid.")
    return
  elsif retry_refused_due_to_truncation?
    io.puts("Cannot retry a run that was cut short during the previous attempt.")
    print_local_results("Combined results were not read for this rejected retry.")
    return
  elsif current_attempt_truncated?
    io.puts("The run was cut short after another worker reached the max-failures limit.")
    print_local_results("Combined results were not read after truncation.")
    return
  elsif configuration.coordinator.aborted?
    print_local_results("Combined results are unavailable because the coordinator aborted this worker.")
    return
  end

  persisted_truncation = configuration.coordinator.persisted_truncation?
  @combined_results = nil
  unless configuration.coordinator.valid_combined_results?
    if persisted_truncation
      io.puts("The run was cut short after reaching the limit of #{configuration.max_failures} test failures.")
    end
    print_local_results("Combined results are unavailable because terminal coordinator state is invalid.")
    return
  end

  if persisted_truncation
    io.puts("The run was cut short after reaching the limit of #{configuration.max_failures} test failures.")
    io.puts
  end

  formatted_duration = format("(in %0.3fs)", Minitest.clock_time - @start_time)
  if combined_results == local_results
    io.puts("Results: #{combined_results} #{formatted_duration}")
  else
    io.puts("This worker:      #{local_results} #{formatted_duration}")
    io.puts("Combined results: #{combined_results}")
  end
end

#start ⇒ Object



18
19
20
21
# File 'lib/minitest/distributed/reporters/distributed_summary_reporter.rb', line 18

def start
  @start_time = Minitest.clock_time
  io.puts("Run options: #{options[:args]}\n\n")
end