Class: Minitest::Queue::WorkerProfileReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/queue/worker_profile_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(supervisor, out: $stdout) ⇒ WorkerProfileReporter

Returns a new instance of WorkerProfileReporter.



6
7
8
9
# File 'lib/minitest/queue/worker_profile_reporter.rb', line 6

def initialize(supervisor, out: $stdout)
  @supervisor = supervisor
  @out = out
end

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/minitest/queue/worker_profile_reporter.rb', line 11

def print_summary
  return unless CI::Queue.debug?

  expected = @supervisor.workers_count
  profiles = {}
  3.times do
    profiles = @supervisor.build.worker_profiles
    break if profiles.size >= expected
    sleep 1
  end
  return if profiles.empty?

  sorted = profiles.values.sort_by { |p| p['worker_id'].to_s }
  mode = sorted.first&.dig('mode') || 'unknown'

  @out.puts
  @out.puts "Worker profile summary (#{sorted.size} workers, mode: #{mode}):"
  @out.puts "  %-12s %-12s %8s %14s %14s %14s %14s %10s" % ['Worker', 'Role', 'Tests', '1st Test', 'Wall Clock', 'Load Tests', 'File Load', 'Memory']
  @out.puts "  #{'-' * 100}"

  sorted.each do |profile|
    @out.puts format_profile_row(profile)
  end

  print_first_test_summary(sorted)
rescue StandardError
  # Don't fail the build if profile printing fails
end