Make ruby-coverage optional until capture starts#43
Closed
samuel-williams-shopify wants to merge 1 commit into
Closed
Make ruby-coverage optional until capture starts#43samuel-williams-shopify wants to merge 1 commit into
samuel-williams-shopify wants to merge 1 commit into
Conversation
Move ruby-coverage from a runtime dependency to a development dependency so applications that only load integrations such as Covered::Sus do not install the native extension unless they actually record coverage. Defer loading covered/capture from Covered::Policy#capture so requiring covered or covered/sus does not immediately require ruby/coverage. If capture is used without ruby-coverage installed, raise a targeted LoadError explaining how to add the optional dependency. Add a Sus regression test that runs in a child process with a trap ruby/coverage file earlier on the load path. Requiring covered/sus with COVERAGE unset must not trigger that file. Validation: PATH=/Users/samuel/.local/state/tec/profiles/base/current/global/bin:$PATH /Users/samuel/.local/state/tec/profiles/base/current/global/bin/bundle exec bake test Validation: /Users/samuel/.local/state/tec/profiles/base/current/global/bin/bundle exec sus test/covered/sus.rb
89aec93 to
1488bad
Compare
Contributor
Author
|
Closing this draft. The better fix is to keep Covered::Sus as-is, since it already defers configuration loading, and handle the optional coverage dependency in the consumer workflow/bundle instead. |
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.
TL;DR
Make
ruby-coverageoptional until coverage capture is actually started, so consumers can loadcovered/suswithout installing or building the nativeruby-coverageextension.Context
This came up while fixing
socketry/io-eventCI.io-eventloadscovered/susfrom its Sus configuration, but normal test jobs do not setCOVERAGE. Even thoughCovered::Susalready avoids loadingCovered::ConfigunlessCOVERAGEis set,coveredstill declaredruby-coverageas a runtime dependency andCovered::Policyeagerly requiredcovered/capture, which requiredruby/coverage.That means applications can pay the native dependency install/build cost even when they are not recording coverage. On platforms where
ruby-coverageis not usable, that fails before tests get to run.Changes
ruby-coveragefrom a runtime dependency to a development dependency.covered/captureloading untilCovered::Policy#captureis used.ruby/coveragerequire inCovered::Capture, but convert missing dependency failures into a targetedLoadErrorexplaining what gem to add when recording coverage.Covered::Susregression test that runs in a child Ruby process with a trapruby/coverage.rbearlier in$LOAD_PATH; requiringcovered/suswithCOVERAGEunset must not trigger that trap.Tophatting