diff --git a/ruby/lib/minitest/queue/build_status_reporter.rb b/ruby/lib/minitest/queue/build_status_reporter.rb index b54c94cc..f677fc8c 100644 --- a/ruby/lib/minitest/queue/build_status_reporter.rb +++ b/ruby/lib/minitest/queue/build_status_reporter.rb @@ -75,6 +75,14 @@ def progress build.progress end + def write_failure_file(file) + File.write(file, error_reports.map(&:to_h).to_json) + end + + def write_flaky_tests_file(file) + File.write(file, flaky_reports.to_json) + end + private attr_reader :build diff --git a/ruby/lib/minitest/queue/runner.rb b/ruby/lib/minitest/queue/runner.rb index 17c49363..f41a69e9 100644 --- a/ruby/lib/minitest/queue/runner.rb +++ b/ruby/lib/minitest/queue/runner.rb @@ -252,7 +252,11 @@ def report_command unless supervisor.exhausted? reporter = BuildStatusReporter.new(build: supervisor.build) reporter.report + reporter.write_failure_file(queue_config.failure_file) if queue_config.failure_file + reporter.write_flaky_tests_file(queue_config.export_flaky_tests_file) if queue_config.export_flaky_tests_file + msg = "#{supervisor.size} tests weren't run." + if supervisor.max_test_failed? puts('Encountered too many failed tests. Test run was ended early.') abort!(msg) @@ -263,18 +267,10 @@ def report_command end reporter = BuildStatusReporter.new(build: supervisor.build) - - if queue_config.failure_file - failures = reporter.error_reports.map(&:to_h).to_json - File.write(queue_config.failure_file, failures) - end - - if queue_config.export_flaky_tests_file - failures = reporter.flaky_reports.to_json - File.write(queue_config.export_flaky_tests_file, failures) - end - + reporter.write_failure_file(queue_config.failure_file) if queue_config.failure_file + reporter.write_flaky_tests_file(queue_config.export_flaky_tests_file) if queue_config.export_flaky_tests_file reporter.report + exit! reporter.success? ? 0 : 1 end