-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
OPA test coverage is not correct when rounding #6307
Labels
Comments
Thanks Anders (and good to see you, btw!). That does indeed sound like an issue to address. |
anderseknert
added a commit
to anderseknert/opa
that referenced
this issue
Oct 11, 2023
Perhaps it looks prettier, but this is only reported in JSON output, so I don't think we should decide on what precision to use there. On coverage < threshold error, we still print using 2 decimals, which is Pretty (tm). Fixes open-policy-agent#6307 Signed-off-by: Anders Eknert <anders@eknert.com>
anderseknert
added a commit
to anderseknert/opa
that referenced
this issue
Oct 11, 2023
Perhaps it looks prettier, but this is only reported in JSON output, so I don't think we should decide on what precision to use there. On coverage < threshold error, we still print using 2 decimals, which is Pretty (tm). Fixes open-policy-agent#6307 Signed-off-by: Anders Eknert <anders@eknert.com>
ashutosh-narkar
pushed a commit
to anderseknert/opa
that referenced
this issue
Oct 11, 2023
Perhaps it looks prettier, but this is only reported in JSON output, so I don't think we should decide on what precision to use there. On coverage < threshold error, we still print using 2 decimals, which is Pretty (tm). Fixes open-policy-agent#6307 Signed-off-by: Anders Eknert <anders@eknert.com>
anderseknert
added a commit
that referenced
this issue
Oct 12, 2023
Perhaps it looks prettier, but this is only reported in JSON output, so I don't think we should decide on what precision to use there. On coverage < threshold error, we still print using 2 decimals, which is Pretty (tm). Fixes #6307 Signed-off-by: Anders Eknert <anders@eknert.com>
Thanks for the swift response! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Short description
OPA version: 0.55.0
We run
opa test . -c --threshold 100
in our build pipeline to keep absolute full code coverage.However, if 1 out of ~12000 lines are not covered, it is treated as 100% and passes the threshold.
I assume golang rounds up to nearest integer at some point when it's close enough, like 99.999999?
The
not_covered_lines
are still reported in the coverage report.Steps To Reproduce
I'm unsure at what number of lines this actually kicks in, but our codebase is over 12000 lines of rego, and it passes threshold of 100 even when 1 or 2 lines are not covered.
Expected behavior
Fail the test coverage threshold when the percentage is mathematically lower.
I suggest to round down to closest nn.dd at all times.
Additional context
The text was updated successfully, but these errors were encountered: