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
Constant Summary collapse
- APPLICATION_ERROR_EXIT_CODE =
42- TIMED_OUT_EXIT_CODE =
43- TOO_MANY_FAILED_TESTS_EXIT_CODE =
44- WORKERS_DIED_EXIT_CODE =
45- SUCCESS_EXIT_CODE =
0- TEST_FAILURE_EXIT_CODE =
1
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
189 190 191 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 189 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
185 186 187 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 185 def errors fetch_summary['errors'].to_i end |
#failures ⇒ Object
181 182 183 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 181 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
205 206 207 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 205 def progress build.progress end |
#record ⇒ Object
177 178 179 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 177 def record(*) raise NotImplementedError end |
#report ⇒ Object
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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 118 def report exit_code = TEST_FAILURE_EXIT_CODE 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 timed_out? 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 exit_code = TIMED_OUT_EXIT_CODE elsif all_workers_died? puts red("All workers died.") exit_code = WORKERS_DIED_EXIT_CODE elsif supervisor.max_test_failed? puts red("Encountered too many failed tests. Test run was ended early.") exit_code = TOO_MANY_FAILED_TESTS_EXIT_CODE 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 "" exit_code = APPLICATION_ERROR_EXIT_CODE end success? ? SUCCESS_EXIT_CODE : exit_code 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
197 198 199 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 197 def requeues fetch_summary['requeues'].to_i end |
#skips ⇒ Object
193 194 195 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 193 def skips fetch_summary['skips'].to_i end |
#success? ⇒ Boolean
168 169 170 171 172 173 174 175 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 168 def success? build.error_reports.empty? && build.worker_errors.empty? && build.queue_exhausted? && !supervisor.max_test_failed? && !all_workers_died? && !timed_out? end |
#total_time ⇒ Object
201 202 203 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 201 def total_time fetch_summary['total_time'].to_f end |
#write_failure_file(file) ⇒ Object
209 210 211 212 213 214 215 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 209 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
217 218 219 220 221 |
# File 'lib/minitest/queue/build_status_reporter.rb', line 217 def write_flaky_tests_file(file) File.open(file, 'w') do |f| JSON.dump(flaky_reports, f) end end |