Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter directories outside SimpleCov.root that have it as a prefix #617

Merged
merged 1 commit into from
Aug 29, 2017

Conversation

jenseng
Copy link
Contributor

@jenseng jenseng commented Aug 29, 2017

Given project directory /foo/app and BUNDLE_PATH /foo/app_cache,
ensure the latter is filtered out correctly by the default root filter,
since it's outside of SimpleCov.root.

Otherwise you'll see all those gem files in your coverage report, with
nonsensical paths like ._cache/ruby/2.4.0/gems..., unless you add a
nonsensical /^_cache/ filter

Also add some test coverage for the default filters

Given project directory `/foo/app` and BUNDLE_PATH `/foo/app_cache`,
ensure the latter is filtered out correctly by the default root filter,
since it's outside of SimpleCov.root.

Otherwise you'll see all those gem files in your coverage report, with
nonsensical paths like `._cache/ruby/2.4.0/gems...`, unless you add a
nonsensical `/^_cache/` filter

Also add some test coverage for the default filters
@jenseng
Copy link
Contributor Author

jenseng commented Aug 29, 2017

Paths are hard, I fixed essentially the same bug in bundler a while back 😂 ... rubygems/bundler#4715

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh thanks a lot! 🎉

@@ -6,7 +6,7 @@
# Exclude all files outside of simplecov root
root_filter = nil
add_filter do |src|
root_filter ||= /\A#{Regexp.escape(SimpleCov.root)}/io
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

@PragTob PragTob merged commit a50b654 into simplecov-ruby:master Aug 29, 2017
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Sep 18, 2017
0.15.1 (2017-09-11)
=======

## Bugfixes

* Filter directories outside SimpleCov.root that have it as a prefix. See [#617](simplecov-ruby/simplecov#617) (thanks @jenseng)
* Fix standard rails profile rails filter (didn't work). See [#618](simplecov-ruby/simplecov#618) (thanks @jenseng again!)
This was referenced Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants