-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
feat(coverage): add option to set coverage threshold #17418
Conversation
Is there a prior art to that? |
Nope, I was trying to simulate how Coveralls calculates this but I got it wrong. What they actually use is: Alternatively, |
IMO following |
@GJZwiers Will you be working on this to align with |
@aapoalas I have not had time to work on this, I'm hoping to have some more time in ~1-1.5 months |
cli/tools/coverage/mod.rs
Outdated
@@ -654,6 +689,7 @@ pub async fn cover_files( | |||
None => None, | |||
}; | |||
|
|||
let mut report_outputs: Vec<ReportOutput> = vec![]; | |||
for script_coverage in script_coverages { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I probably messed up in the merge here and removed the borrow from &script_coverages
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have a spare borrow laying around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you for a magnificent feature!
The code seems good, tests are done, calculation of coverage is implemented according to istanbul which was recommended by @bartlomieju so I see no reason to keep this as a Draft anymore. I'd be willing to merge this as well.
Thanks for approving @aapoalas! I am OK with landing this as is, although I had a few concerns left which is why I kept it as a draft. The current implementation works but is also fairly basic, other implementations have separate flags for each type of coverage e.g. |
Any reason for why this was closed without being merged ? It looks close to be shippable |
@lowlighter I closed this because I decided to do other things, but the code was pretty much ready to be merged. If you want to make a PR and revive this you are welcome to do so. |
This PR implements part of #9669 by adding a
--threshold
flag todeno coverage
that will cause the program to throw an Error if the collected coverage % is lower. Right now there is no default threshold set (well technically 0%) because I am not sure what it should be or if there should even be a default.The line, branch and function coverages are compared and the program will throw if any one falls below the set threshold.