Class: Minitest::Queue::BuildStatusReporter

Inherits:
Reporters::BaseReporter
  • Object
show all
Includes:
CI::Queue::OutputHelpers
Defined in:
lib/minitest/queue/build_status_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(build:, **options) ⇒ BuildStatusReporter

Returns a new instance of BuildStatusReporter.



7
8
9
10
# File 'lib/minitest/queue/build_status_reporter.rb', line 7

def initialize(build:, **options)
  @build = build
  super(options)
end

Instance Method Details

#assertionsObject



65
66
67
# File 'lib/minitest/queue/build_status_reporter.rb', line 65

def assertions
  fetch_summary['assertions'].to_i
end

#completed?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/minitest/queue/build_status_reporter.rb', line 12

def completed?
  build.queue_exhausted?
end

#error_reportsObject



16
17
18
# File 'lib/minitest/queue/build_status_reporter.rb', line 16

def error_reports
  build.error_reports.sort_by(&:first).map { |k, v| ErrorReport.load(v) }
end

#errorsObject



61
62
63
# File 'lib/minitest/queue/build_status_reporter.rb', line 61

def errors
  fetch_summary['errors'].to_i
end

#failuresObject



57
58
59
# File 'lib/minitest/queue/build_status_reporter.rb', line 57

def failures
  fetch_summary['failures'].to_i
end

#flaky_reportsObject



20
21
22
# File 'lib/minitest/queue/build_status_reporter.rb', line 20

def flaky_reports
  build.flaky_reports
end

#progressObject



81
82
83
# File 'lib/minitest/queue/build_status_reporter.rb', line 81

def progress
  build.progress
end

#recordObject

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/minitest/queue/build_status_reporter.rb', line 53

def record(*)
  raise NotImplementedError
end

#reportObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/minitest/queue/build_status_reporter.rb', line 28

def report
  puts aggregates
  errors = error_reports
  puts errors

  requeued_tests.to_a.sort.each do |test_id, count|
    puts yellow("REQUEUE")
    puts "#{test_id} (requeued #{count} times)"
    puts ""
  end

  build.worker_errors.to_a.sort.each do |worker_id, error|
    puts red("Worker #{worker_id } crashed")
    puts error
    puts ""
  end

  errors.empty?
end

#requeued_testsObject



24
25
26
# File 'lib/minitest/queue/build_status_reporter.rb', line 24

def requeued_tests
  build.requeued_tests
end

#requeuesObject



73
74
75
# File 'lib/minitest/queue/build_status_reporter.rb', line 73

def requeues
  fetch_summary['requeues'].to_i
end

#skipsObject



69
70
71
# File 'lib/minitest/queue/build_status_reporter.rb', line 69

def skips
  fetch_summary['skips'].to_i
end

#success?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/minitest/queue/build_status_reporter.rb', line 48

def success?
  build.error_reports.empty? &&
    build.worker_errors.empty?
end

#total_timeObject



77
78
79
# File 'lib/minitest/queue/build_status_reporter.rb', line 77

def total_time
  fetch_summary['total_time'].to_f
end

#write_failure_file(file) ⇒ Object



85
86
87
# File 'lib/minitest/queue/build_status_reporter.rb', line 85

def write_failure_file(file)
  File.write(file, error_reports.map(&:to_h).to_json)
end

#write_flaky_tests_file(file) ⇒ Object



89
90
91
# File 'lib/minitest/queue/build_status_reporter.rb', line 89

def write_flaky_tests_file(file)
  File.write(file, flaky_reports.to_json)
end