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

policy test coverage lists variables under not_covered #1972

Closed
segrax opened this issue Dec 21, 2019 · 1 comment · Fixed by #2062
Closed

policy test coverage lists variables under not_covered #1972

segrax opened this issue Dec 21, 2019 · 1 comment · Fixed by #2062
Assignees
Labels

Comments

@segrax
Copy link
Contributor

segrax commented Dec 21, 2019

Expected Behavior

variables are either marked as covered when used or just ignored completely?

Actual Behavior

any variable, whether its used or not is listed as 'not_covered' in the coverage report

Steps to Reproduce the Problem

Using the example policy and test from Getting Started

opa test /srv/app/example.rego /srv/app/example_test.rego -v --coverage --format=json

the coverage report indicates that row 9 is not covered

"not_covered": [
        {
          "start": {
            "row": 9
          },
          "end": {
            "row": 9
          }
        }
      ],

Line 9 of example.rego reads 'some profile_id' (which is referenced in line 12)
image

Additional Info

Version: 0.16.0
Build Commit: b50e626
Build Timestamp: 2019-12-19T13:13:32Z
Build Hostname: 08f277b56fc6

@tsandall
Copy link
Member

tsandall commented Jan 9, 2020

@segrax thanks for filing this! Sorry for the delayed response (reason: holidays, catching up on issues/emails after coming back, etc.)

This looks like a bug in the coverage reporter/calculation (cover/cover.go). The problem (I think) is that some statements do not actually get evaluated (they're used for semantic checks but the evaluator doesn't look at them.) The coverage reporter is probably should just exclude these statements when checking whether statements have been executed.

@tsandall tsandall added the bug label Jan 9, 2020
@patrick-east patrick-east self-assigned this Feb 6, 2020
patrick-east added a commit to patrick-east/opa that referenced this issue Feb 6, 2020
They would previously show up as not-covered in any report. This
changes to simply omit them. They will never be int the resulting
covered or not-covered lists, or count against the % covered.

Fixes: open-policy-agent#1972
Signed-off-by: Patrick East <east.patrick@gmail.com>
tsandall pushed a commit that referenced this issue Feb 12, 2020
They would previously show up as not-covered in any report. This
changes to simply omit them. They will never be int the resulting
covered or not-covered lists, or count against the % covered.

Fixes: #1972
Signed-off-by: Patrick East <east.patrick@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants