Skip to content

Commit

Permalink
Always write report files
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed May 10, 2024
1 parent 7bb8625 commit f543e23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 8 additions & 0 deletions ruby/lib/minitest/queue/build_status_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 7 additions & 11 deletions ruby/lib/minitest/queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit f543e23

Please sign in to comment.