Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always write report files #277

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading