Skip to content

Commit

Permalink
Make it easier to run coverage reports locally (#1750)
Browse files Browse the repository at this point in the history
* Make it easier to run coverage reports locally

This keeps simplecov's command names separate so that they don't
overwrite each other when running locally.

(In CI we generate one coverage/.resultset.json for each
RAILS_VERSION/RUBY_VERSION set, and then those are downloaded to
separate directories for the final `rake coverage:report`, so it's not
necessary there)

* Update test/test_helper.rb

---------

Co-authored-by: Joel Hawksley <[email protected]>
Co-authored-by: Joel Hawksley <[email protected]>
  • Loading branch information
3 people authored May 23, 2023
1 parent 649a5bd commit 3b3a37f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace :coverage do

SimpleCov.minimum_coverage 100

SimpleCov.collate Dir["simplecov-resultset-*/.resultset.json"], "rails" do
SimpleCov.collate Dir["{coverage,simplecov-resultset-*}/.resultset.json"], "rails" do
formatter SimpleCov::Formatter::Console
end
end
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ nav_order: 5

*Joseph Carpenter*

* Fix coverage reports overwriting each other when running locally.

*Jonathan del Strother*

### v3.0.0

1,000+ days and 100+ releases later, the 200+ contributors to ViewComponent are proud to ship v3.0.0!
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

require "simplecov"
require "simplecov-console"
require "rails/version"

if ENV["MEASURE_COVERAGE"]
SimpleCov.start do
command_name "rails#{ENV["RAILS_VERSION"]}-ruby#{ENV["RUBY_VERSION"]}" if ENV["RUBY_VERSION"]
command_name "RSpec-rails#{Rails::VERSION::STRING}-ruby#{RUBY_VERSION}"

formatter SimpleCov::Formatter::Console
end
Expand Down
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

require "simplecov"
require "simplecov-console"
require "rails/version"

if ENV["MEASURE_COVERAGE"]
SimpleCov.start do
command_name "rails#{ENV["RAILS_VERSION"]}-ruby#{ENV["RUBY_VERSION"]}" if ENV["RUBY_VERSION"]
command_name "minitest-rails#{Rails::VERSION::STRING}-ruby#{RUBY_VERSION}"

formatter SimpleCov::Formatter::Console
end
Expand Down

0 comments on commit 3b3a37f

Please sign in to comment.