Merge pull request #18639 from Homebrew/improve_parallel_tests

spec_helper: improve parallel test handling.
This commit is contained in:
Bo Anderson 2024-10-27 16:34:49 +00:00 committed by GitHub
commit 91f3671b16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,10 +10,14 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
]
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)
if RUBY_PLATFORM[/darwin/] && ENV["TEST_ENV_NUMBER"]
# Needed for outputting coverage reporting only once for parallel_tests.
# Otherwise, "Coverage report generated" will get spammed for each process.
if ENV["TEST_ENV_NUMBER"]
SimpleCov.at_exit do
result = SimpleCov.result
result.format! if ParallelTests.number_of_running_processes <= 1
# `SimpleCov.result` calls `ParallelTests.wait_for_other_processes_to_finish`
# internally for you on the last process.
result.format! if ParallelTests.last_process?
end
end
end