Class: Minitest::Queue::BuildStatusReporter
- Inherits:
-
Reporters::BaseReporter
- Object
- Reporters::BaseReporter
- Minitest::Queue::BuildStatusReporter
- Includes:
- CI::Queue::OutputHelpers
- Defined in:
- lib/minitest/queue/build_status_reporter.rb
Defined Under Namespace
Classes: JUnitReporter
Instance Method Summary collapse
- #assertions ⇒ Object
- #completed? ⇒ Boolean
- #error_reports ⇒ Object
- #errors ⇒ Object
- #failures ⇒ Object
- #flaky_reports ⇒ Object
-
#initialize(supervisor:, **options) ⇒ BuildStatusReporter
constructor
A new instance of BuildStatusReporter.
- #progress ⇒ Object
- #record ⇒ Object
- #report ⇒ Object
- #requeued_tests ⇒ Object
- #requeues ⇒ Object
- #skips ⇒ Object
- #success? ⇒ Boolean
- #total_time ⇒ Object
- #write_failure_file(file) ⇒ Object
- #write_flaky_tests_file(file) ⇒ Object
Constructor Details
#initialize(supervisor:, **options) ⇒ BuildStatusReporter
Returns a new instance of BuildStatusReporter.
89 90 91 92 93 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 89 def initialize(supervisor:, **) @supervisor = supervisor @build = supervisor.build super() end |
Instance Method Details
#assertions ⇒ Object
171 172 173 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 171 def assertions fetch_summary['assertions'].to_i end |
#completed? ⇒ Boolean
95 96 97 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 95 def completed? build.queue_exhausted? end |
#error_reports ⇒ Object
99 100 101 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 99 def error_reports build.error_reports.sort_by(&:first).map { |k, v| ErrorReport.load(v) } end |
#errors ⇒ Object
167 168 169 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 167 def errors fetch_summary['errors'].to_i end |
#failures ⇒ Object
163 164 165 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 163 def failures fetch_summary['failures'].to_i end |
#flaky_reports ⇒ Object
103 104 105 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 103 def flaky_reports build.flaky_reports end |
#progress ⇒ Object
187 188 189 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 187 def progress build.progress end |
#record ⇒ Object
159 160 161 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 159 def record(*) raise NotImplementedError end |
#report ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 111 def report if requeued_tests.to_a.any? step("Requeued #{requeued_tests.size} tests") requeued_tests.to_a.sort.each do |test_id, count| puts yellow("REQUEUE") puts "#{test_id} (requeued #{count} times)" puts "" end end puts aggregates if supervisor.time_left.to_i <= 0 puts red("Timed out waiting for tests to be executed.") remaining_tests = supervisor.test_ids remaining_tests.first(10).each do |id| puts " #{id}" end if remaining_tests.size > 10 puts " ..." end elsif supervisor.time_left_with_no_workers.to_i <= 0 puts red("All workers died.") elsif supervisor.max_test_failed? puts red("Encountered too many failed tests. Test run was ended early.") end puts errors = error_reports puts errors build.worker_errors.to_a.sort.each do |worker_id, error| puts red("Worker #{worker_id } crashed") puts error puts "" end success? end |
#requeued_tests ⇒ Object
107 108 109 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 107 def requeued_tests build.requeued_tests end |
#requeues ⇒ Object
179 180 181 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 179 def requeues fetch_summary['requeues'].to_i end |
#skips ⇒ Object
175 176 177 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 175 def skips fetch_summary['skips'].to_i end |
#success? ⇒ Boolean
154 155 156 157 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 154 def success? build.error_reports.empty? && build.worker_errors.empty? end |
#total_time ⇒ Object
183 184 185 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 183 def total_time fetch_summary['total_time'].to_f end |
#write_failure_file(file) ⇒ Object
191 192 193 194 195 196 197 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 191 def write_failure_file(file) File.open(file, 'w') do |f| JSON.dump(error_reports.map(&:to_h), f) end xml_file = File.join(File.dirname(file), "#{File.basename(file, File.extname(file))}.xml") JUnitReporter.new(xml_file, error_reports).write end |
#write_flaky_tests_file(file) ⇒ Object
199 200 201 202 203 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 199 def write_flaky_tests_file(file) File.open(file, 'w') do |f| JSON.dump(flaky_reports, f) end end |