-
Notifications
You must be signed in to change notification settings - Fork 553
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
Support for minimal coverage and maximal coverage drop #151
Conversation
Link to the Travis build: http://travis-ci.org/#!/infertux/simplecov/builds/1927262 |
Great stuff. I read through the code and you did well, special bonus points for nice cucumber features :) That at_exit block in SimpleCov is getting a bit unwieldy right now, I think that will need some refactoring soon. I created a separate issue (#153) for that. Two things:
Thanks for your effort! |
Yeah, I think this bit should be extracted to some separate file but I'll let you go with whatever makes more sense to you.
Good call - also added different exit codes for each error.
Agreed,
No problem! :) |
Support for minimal coverage and maximal coverage drop
Awesome! |
Is there any way to have it so fractional coverage thresholds can be specified, like I know there are problems comparing floats, but we could always coerce to a |
Yeah, I saw in the original commits that it only works with fixnums and was thinking the same, but then I thought again: Who the hell would want to specify a non-int threshold? If there is a use case for that I guess we could make it do :) |
The way I usually use coverage testing is that when I come onto a project where I add coverage, my goal is to ensure that all the code I add never decreases coverage. Ideally it's increasing, but at the very least I don't want it to drop at all. So what I do is the first time I run the coverage I take the coverage result that is returned and I set that as my threshold. I effectively draw a line in the sand and say "the coverage should never get any worse". Every time I increase the coverage I increase the threshold. I actually do this with several different kinds of metrics. It's true sometimes there is a special case and I have to manually adjust them downwards, but when that happens it's not by accident. I think that's a key point, most drops in code quality happen when people aren't paying attention or when you get lazy. In my case I fail the build if anything drops below my thresholds and I have to make the call on whether or not to fix it or adjust the thresholds. |
So I guess to make a long story short, it would be really nice to be able to make tiny incremental increases in the thresholds over time, rather than having to make whole number jumps in the thresholds. |
+1 For @dkubb's use case :) |
FIrst off all, I didn't think about this use case when I initially used However, using Also, you may be interested by #11 (comment). @colszowka: Is there a new release including the new features planned in the near future? |
@infertux I tested that branch and saw the following error:
I'm guessing that what is happening is that when the coverage is calculated it's using fractional numbers, like 91.600001 or anything above 91.6. I'm guessing that the coverage and the threshold should be rounded down and then compared. For my purposes anything rounded to the nearest 1/10th is probably good enough. |
Yes, the actual comparison is correct but the output is misleading because >> '%.2f' % 91.596
=> "91.60" So numbers are now rounded down to 2 digits then compared to avoid confusion. 1/100th should be accurate enough for all use cases and is consistent with the HTML report which displays 2 digits as well. Thanks for the report! :) |
Make this package to Ruby 1.9.3 only. v0.7.1, 2012-10-12 ([changes](simplecov-ruby/simplecov@v0.7.0...v0.7.1)) ------------------- * [BUGFIX] The gem packages of 0.7.0 (both simplecov and simplecov-html) pushed to Rubygems had some file permission issues, leading to problems when installing SimpleCov in a root/system Rubygems install and then trying to use it as a normal user (see simplecov-ruby/simplecov#171, thanks @envygeeks for bringing it up). The gem build process has been changed to always enforce proper permissions before packaging to avoid this issue in the future. v0.7.0, 2012-10-10 ([changes](simplecov-ruby/simplecov@v0.6.4...v0.7.0)) ------------------- * [FEATURE] The new `maximum_coverage_drop` and `minimum_coverage` now allow you to fail your build when the coverage dropped by more than what you allowed or is below a minimum value required. Also, `refuse_coverage_drop` disallows any coverage drops between test runs. See simplecov-ruby/simplecov#151, simplecov-ruby/simplecov#11, simplecov-ruby/simplecov#90, and simplecov-ruby/simplecov#96 (thanks to @infertux) * [FEATURE] SimpleCov now ships with a built-in MultiFormatter which allows the easy usage of multiple result formatters at the same time without the need to write custom wrapper code. See simplecov-ruby/simplecov#158 (thanks to @nikitug) * [BUGFIX] The usage of digits, hyphens and underscores in group names could lead to broken tab navigation in the default simplecov-html reports. See simplecov-ruby/simplecov-html#14 (thanks to @ebelgarts) * [REFACTORING] A few more ruby warnings removed. See simplecov-ruby/simplecov#106 and simplecov-ruby/simplecov#139. (thanks to @lukejahnke) * A [Pledgie button](simplecov-ruby/simplecov@63cfa99) for those that feel generous :) * The usual bunch of README fixes and documentation tweaks. Thanks to everyone who contributed those!
Make this package to Ruby 1.9.3 only. v0.7.1, 2012-10-12 ([changes](simplecov-ruby/simplecov@v0.7.0...v0.7.1)) ------------------- * [BUGFIX] The gem packages of 0.7.0 (both simplecov and simplecov-html) pushed to Rubygems had some file permission issues, leading to problems when installing SimpleCov in a root/system Rubygems install and then trying to use it as a normal user (see simplecov-ruby/simplecov#171, thanks @envygeeks for bringing it up). The gem build process has been changed to always enforce proper permissions before packaging to avoid this issue in the future. v0.7.0, 2012-10-10 ([changes](simplecov-ruby/simplecov@v0.6.4...v0.7.0)) ------------------- * [FEATURE] The new `maximum_coverage_drop` and `minimum_coverage` now allow you to fail your build when the coverage dropped by more than what you allowed or is below a minimum value required. Also, `refuse_coverage_drop` disallows any coverage drops between test runs. See simplecov-ruby/simplecov#151, simplecov-ruby/simplecov#11, simplecov-ruby/simplecov#90, and simplecov-ruby/simplecov#96 (thanks to @infertux) * [FEATURE] SimpleCov now ships with a built-in MultiFormatter which allows the easy usage of multiple result formatters at the same time without the need to write custom wrapper code. See simplecov-ruby/simplecov#158 (thanks to @nikitug) * [BUGFIX] The usage of digits, hyphens and underscores in group names could lead to broken tab navigation in the default simplecov-html reports. See simplecov-ruby/simplecov-html#14 (thanks to @ebelgarts) * [REFACTORING] A few more ruby warnings removed. See simplecov-ruby/simplecov#106 and simplecov-ruby/simplecov#139. (thanks to @lukejahnke) * A [Pledgie button](simplecov-ruby/simplecov@63cfa99) for those that feel generous :) * The usual bunch of README fixes and documentation tweaks. Thanks to everyone who contributed those!
Make this package to Ruby 1.9.3 only. v0.7.1, 2012-10-12 ([changes](simplecov-ruby/simplecov@v0.7.0...v0.7.1)) ------------------- * [BUGFIX] The gem packages of 0.7.0 (both simplecov and simplecov-html) pushed to Rubygems had some file permission issues, leading to problems when installing SimpleCov in a root/system Rubygems install and then trying to use it as a normal user (see simplecov-ruby/simplecov#171, thanks @envygeeks for bringing it up). The gem build process has been changed to always enforce proper permissions before packaging to avoid this issue in the future. v0.7.0, 2012-10-10 ([changes](simplecov-ruby/simplecov@v0.6.4...v0.7.0)) ------------------- * [FEATURE] The new `maximum_coverage_drop` and `minimum_coverage` now allow you to fail your build when the coverage dropped by more than what you allowed or is below a minimum value required. Also, `refuse_coverage_drop` disallows any coverage drops between test runs. See simplecov-ruby/simplecov#151, simplecov-ruby/simplecov#11, simplecov-ruby/simplecov#90, and simplecov-ruby/simplecov#96 (thanks to @infertux) * [FEATURE] SimpleCov now ships with a built-in MultiFormatter which allows the easy usage of multiple result formatters at the same time without the need to write custom wrapper code. See simplecov-ruby/simplecov#158 (thanks to @nikitug) * [BUGFIX] The usage of digits, hyphens and underscores in group names could lead to broken tab navigation in the default simplecov-html reports. See simplecov-ruby/simplecov-html#14 (thanks to @ebelgarts) * [REFACTORING] A few more ruby warnings removed. See simplecov-ruby/simplecov#106 and simplecov-ruby/simplecov#139. (thanks to @lukejahnke) * A [Pledgie button](simplecov-ruby/simplecov@63cfa99) for those that feel generous :) * The usual bunch of README fixes and documentation tweaks. Thanks to everyone who contributed those!
Here is a proposal to implement two new features:
min_coverage
)max_coverage_difference
)Please let me know if you're happy with this so I would add some explanations in the README.
Also, I extracted the JSON handling to a separate file to avoid code duplication between
result_merger.rb
andlast_run.rb
.Thanks for this neat Gem :).