spec_helper: improve parallel test handling.

- Clarify the comment of why we have SimpleCov special logic for
  parallel tests
- use a nicer ParallelTests API for checking which process to output
  the coverage format on
This commit is contained in:
Mike McQuaid 2024-10-26 11:20:37 +01:00
parent 59d56f84ac
commit 92fee908ba
No known key found for this signature in database

View File

@ -10,10 +10,11 @@ if ENV["HOMEBREW_TESTS_COVERAGE"]
] ]
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters) SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters)
# Needed for outputting coverage reporting only once for parallel_tests
if RUBY_PLATFORM[/darwin/] && ENV["TEST_ENV_NUMBER"] if RUBY_PLATFORM[/darwin/] && ENV["TEST_ENV_NUMBER"]
SimpleCov.at_exit do SimpleCov.at_exit do
result = SimpleCov.result result = SimpleCov.result
result.format! if ParallelTests.number_of_running_processes <= 1 result.format! if ParallelTests.last_process?
end end
end end
end end