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

Threshold not fail when no module #1115

Merged
merged 5 commits into from
Mar 25, 2021

Conversation

daveMueller
Copy link
Collaborator

closes #1083

@daveMueller daveMueller marked this pull request as draft March 8, 2021 00:25
@daveMueller daveMueller changed the title Threshold not fail when no module [WIP] Threshold not fail when no module Mar 8, 2021
@daveMueller
Copy link
Collaborator Author

An output like the following

+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 100% | 100%   | 100%   |
+---------+------+--------+--------+
| Average | NaN% | NaN%   | NaN%   |
+---------+------+--------+--------+

currently only happens when for what ever reason the Modules are empty. In the first part of the summary there is no entry because no Module exists in the result. That is also the reason why Average is NaN because there is a division by zero (Modules.Count=0).
As the issue already stated a coverage of 100% is the wrong value to return in this case.

There are two solution I can think of. One would throw an exception. Something like "No coverage could be calculated because the result doesn't contain any modules." However this might break some CI pipelines just because coverage has an issue.

The other solution would be to return a coverage of 0 when this happens. This is what I prepared in this PR. But personally I'm a bit divided about this. What do you think, @MarcoRossignoli @martincostello ?

image

@daveMueller daveMueller marked this pull request as ready for review March 25, 2021 05:12
@daveMueller daveMueller changed the title [WIP] Threshold not fail when no module Threshold not fail when no module Mar 25, 2021
@martincostello
Copy link
Contributor

Yeah I think 0% is better, as then the coverage threshold will take effect if it's configured and fail the build that way.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Mar 25, 2021

I agree with Martin, go for 0% and fail if there is a threshold check.

Thx Dave.

Copy link
Collaborator

@MarcoRossignoli MarcoRossignoli left a comment

Choose a reason for hiding this comment

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

LGTM

@MarcoRossignoli MarcoRossignoli merged commit b1c20d5 into coverlet-coverage:master Mar 25, 2021
@MarcoRossignoli
Copy link
Collaborator

@daveMueller remember to update the changelog thx a lot!

@daveMueller daveMueller deleted the 1083_Threshold branch March 26, 2021 07:52
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.

Code coverage threshold does not fail if no coverage generated
3 participants