Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces code coverage collection for the RubyGems (Test::Unit) and Bundler (RSpec) test suites using SimpleCov, and adds a rake task to collate results into a report under coverage/.
Changes:
- Add
simplecovas a development dependency for the Bundler dev bundle. - Start coverage collection from RubyGems tests and Bundler specs, and introduce an early-boot coverage preload for RubyGems.
- Add a
coverage:reportrake task and automatically run it afterrake testandrake spec:regular.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tool/bundler/dev_gems.rb | Adds simplecov to the Bundler dev bundle dependencies. |
| test/rubygems/helper.rb | Attempts to start SimpleCov during RubyGems test helper load. |
| test/rubygems/coverage_setup.rb | New preload file to start coverage before requiring RubyGems. |
| bundler/spec/spec_helper.rb | Attempts to start SimpleCov for the Bundler spec suite. |
| Rakefile | Preloads coverage setup for rake test, adds coverage:report, and hooks report generation after test/spec tasks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+769
to
+774
| Rake::Task[:test].enhance do | ||
| Rake::Task["coverage:report"].reenable | ||
| Rake::Task["coverage:report"].invoke end | ||
| Rake::Task["spec:regular"].enhance do | ||
| Rake::Task["coverage:report"].reenable | ||
| Rake::Task["coverage:report"].invoke end |
| # of rubygems boot files. It must be used with --disable-gems and -Ilib | ||
| # so that Coverage.start runs before rubygems is loaded. | ||
|
|
||
| require "coverage" |
| begin | ||
| raise LoadError if ENV["GEM_COMMAND"] | ||
|
|
||
| gem "simplecov_json_formatter" |
Comment on lines
+43
to
+52
| begin | ||
| raise LoadError if File.exist?(File.expand_path("../../../lib/bundler/bundler.gemspec", __dir__)) | ||
|
|
||
| gem "simplecov_json_formatter" | ||
| require "simplecov" | ||
|
|
||
| SimpleCov.start do | ||
| command_name "bundler:#{Process.pid}" | ||
| root File.expand_path("../..", __dir__) | ||
| coverage_dir File.expand_path("../../coverage", __dir__) |
| begin | ||
| raise LoadError if File.exist?(File.expand_path("../../../lib/bundler/bundler.gemspec", __dir__)) | ||
|
|
||
| gem "simplecov_json_formatter" |
Rakefile
Outdated
Comment on lines
+93
to
+94
| require "simplecov" | ||
| SimpleCov.collate Dir["coverage/.resultset.json"] do |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add coverage_setup.rb loaded via -r flag before rubygems to enable Coverage tracking of boot files. SimpleCov is configured in helper.rb to collect coverage data for rubygems test suite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Configure SimpleCov in spec_helper.rb to collect coverage data for the bundler test suite, outputting results to the shared coverage directory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When running bundler specs with parallel_rspec, each worker process needs a unique command_name to prevent overwriting each other's coverage results in .resultset.json. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add coverage:report task using SimpleCov.collate to merge results from both test suites. Auto-run after test and spec:regular tasks. Add convenience rake coverage task to run both suites. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Skip SimpleCov setup when running inside the ruby/ruby repository to avoid interference. Detection uses GEM_COMMAND env var for rubygems and bundler.gemspec presence for bundler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Guard coverage:report task against missing SimpleCov or missing resultset file so that rake test and spec:regular do not fail in environments without SimpleCov installed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The code for Rubygems and Bundler is quite old, so it's difficult to gauge whether a piece of code is still in use or needed. So I'm going to start by creating coverage using
SimpleCov.Usage
Make sure the following tasks are checked