Opa: policy test coverage lists variables under not_covered

Created on 21 Dec 2019  路  1Comment  路  Source: open-policy-agent/opa

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

bug

Most helpful comment

@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.

>All comments

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gshively11 picture gshively11  路  8Comments

kadimulam picture kadimulam  路  8Comments

kenfdev picture kenfdev  路  3Comments

kennethmyers picture kennethmyers  路  3Comments

PriyaKatkade picture PriyaKatkade  路  4Comments