Comments (6)
Hey, may I humbly suggest to RTFM :)
Under the Groups section of the Readme there's an explanation on how to define groups. You can do that by supplying a block as well, which will then yield each source file (check the rdoc on the public api of that) to that block, so you could check the path of the file and reject all those that are in your subdirectory.
Hope this helps!
from simplecov.
I did RTFM. And I know about the block and it's seems to me a rather inefficient approach. I was hoping there might be a better way and if not, I would suggest that there should be.
May I humbly suggest you refrain from using RTFM as an answer :)
from simplecov.
Oh, sorry, since you did not mention the block syntax for group definition, I figured you missed out on it :)
Unfortunately, adding your proposed syntax would require SimpleCov to extend/monkey patch Ruby's String literals to be aware of Path names and also to add the "-" method to String which, even though this method does not exist in MRI right now, would be a very bad practice IMHO since it is a very low-level method name and might be added in future Ruby versions to Strings.
What would be possible would be to create a Subclass for String that has those features, which would result in something like
add_group "Foo", SrcPath('lib/foo') - SrcPath('lib/foo/bar')
I think this looks rather clumsy though and adds unneccessary complexity through obscurity, since the block version might be almost the same, though in a bit more expressive way:
add_group("Foo") {|src| src.filename.include?('lib/foo') and not src.filename.include?('lib/foo/bar') }
from simplecov.
Thanks. Actually I should have peaked at the code a bit more myself. I assumed that the "filter" argument was doing some sort of Dir.glob
to segment things. I see now that every path is just going through a selection block in the end. So your block solution is no less efficient. (Is my analysis right?)
It also means that File.fnmatch?
syntax can't be used in the filter. Didn't realize that.
Note though you could do:
add_group(group_name, filter_argument=nil, options={}, &filter_proc)
Allowing something like:
add_group "Foo", 'lib/foo', :omit => 'lib/foo/bar'
Or you could take it even further to handle fnmatch globs too:
add_group "FooS", :glob => 'lib/foo/s*.rb'
Food for thought. Thanks again.
from simplecov.
Yeah, makes sense - maybe this should get refactored to use Ruby's built-in path functionalities like you mentioned. Reopening this as a reminder to investigate :)
from simplecov.
Closing as stale. Please reopen if this is still an issue. (And take a look at #340 )
from simplecov.
Related Issues (20)
- Fix code coverage (eval) for delegates
- Bug: random branch coverage data in most cases. HOT 2
- Reporting branch coverage percentage in the terminal output HOT 2
- branch coverage data missing after collating .resultset.json in parallel test HOT 2
- allow skipping (unreachable) branch coverage only HOT 10
- option to disable line warnings with `enable_coverage_for_eval` and rails views HOT 3
- Use of ractors makes coverage non-deterministic HOT 3
- Branch coverage for the files which don't have _spec files
- "Coverage report generated" is being written to the stdout stream
- Default configurations around coverage criteria and minimum coverage
- Minor documentation fix
- [Feature Request] Don't require all branches to be covered twice in ensure-blocks HOT 3
- Support for other Parallel Testing gems
- SimpleCov does not fail for low coverage for parallel_tests when using 1 process
- SimpleCov only reports the last controller test and sets to 0.0% all previous results HOT 1
- False positives for `begin` lines, a constant definition, and some heredoc content
- مشکل <3
- Rails 7.1 update => test coverage drop HOT 6
- Coverage changes after each run HOT 1
- 0.22.0 release is missing on GitHub
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplecov.