Files
openfoodnetwork/lib/tasks/simplecov.rake
Maikel Linke 2555a9e710 Ignore breaking code coverage for coverage spec
When we test our code coverage compilation, it breaks the code coverage
report for the current rspec process. By running that code separately,
we gain a correct coverage report for the rest of the code again.

So unfortunately, we can't report on the code coverage of this
particular task and have to ignore it. But at least CI depends on the
correct function of this task and would fail if it didn't work.
2025-08-05 12:45:05 +10:00

28 lines
1.0 KiB
Ruby

# frozen_string_literal: true
namespace :simplecov do
desc "Collates all result sets produced during parallel test runs"
task :collate_results, # rubocop:disable Rails/RakeEnvironment doesn't need the full env
[:path_to_results, :coverage_dir] do |_t, args|
# This code is covered by a spec but trying to measure the code coverage of
# the spec breaks the coverage report. We need to ignore it to avoid warnings.
# :nocov:
require "simplecov"
require "undercover/simplecov_formatter"
path_to_results = args[:path_to_results].presence || "tmp/simplecov"
output_path = args[:coverage_dir].presence || "coverage"
SimpleCov.collate Dir[File.join(path_to_results, "**", ".resultset.json")], "rails" do
formatter(SimpleCov::Formatter::HTMLFormatter)
coverage_dir(output_path)
end
SimpleCov.collate Dir[File.join(path_to_results, "**", ".resultset.json")], "rails" do
formatter(SimpleCov::Formatter::Undercover)
coverage_dir(output_path)
end
# :nocov:
end
end