Skip to content

CEL test coverage calculation#1209

Merged
jnthntatum merged 2 commits intogoogle:masterfrom
aakash070:cel_test_coverage
Sep 3, 2025
Merged

CEL test coverage calculation#1209
jnthntatum merged 2 commits intogoogle:masterfrom
aakash070:cel_test_coverage

Conversation

@aakash070
Copy link
Collaborator

@aakash070 aakash070 commented Aug 20, 2025

This change adds coverage calculation logic for the CEL test runner:

  1. The cel_go_test bazel macro accepts a new boolean flag enable_coverage. When set to True the coverage statistics for the test suite are logged.
  2. Coverage metrics include:
  • AST node coverage - Determines the percentage of AST nodes covered
  • AST branch coverage - Determines the percentage of logical branches covered
    For each of the above metrics, an optional set of interesting nodes and branches are logged which can help determine which nodes or logical branches are missed by the tests.

Sample coverage logs for //policy:restricted_destinations_policy:
restricted_destinations_policy

Copy link
Collaborator

@jnthntatum jnthntatum left a comment

Choose a reason for hiding this comment

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

LGTM.

Still not sure on the best way to present the details on missing coverage: it may make sense to just present the high level stats by default and add a flag or other mechanism to opt into dumping the missing coverage snippets, but I'll defer to other reviewers.

bypass cel.@block function from branch coverage

added nil check on coverage stats stored in the Program object passed to traverseAndCalculateCoverage

moved start log statement to printCoverageReport method

moved coverage reporting to a separate file to allow simpler copybara import

changed key type of set to ref.Val

code refactor to log cel block boolean index variables and remove redundant boolean flag
jnthntatum
jnthntatum previously approved these changes Aug 29, 2025
@jnthntatum jnthntatum merged commit b24530c into google:master Sep 3, 2025
2 checks passed
renevo pushed a commit to Blizzard/cel-go that referenced this pull request Sep 12, 2025
* added cel test coverage calculation and tests
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.

3 participants