MCPcopy Create free account
hub / github.com/cel-expr/cel-go / collectCoverageStats

Function collectCoverageStats

tools/celtest/test_runner.go:1047–1067  ·  view source on GitHub ↗

collectCoverageStats collects the coverage stats from the EvalDetails and stores them in the CoverageStats map of the Program.

(details *cel.EvalDetails, p *Program)

Source from the content-addressed store, hash-verified

1045// collectCoverageStats collects the coverage stats from the EvalDetails and stores them in the
1046// CoverageStats map of the Program.
1047func collectCoverageStats(details *cel.EvalDetails, p *Program) {
1048 if details == nil || details.State() == nil {
1049 return
1050 }
1051 if p.CoverageStats == nil {
1052 p.CoverageStats = make(map[int64]set)
1053 }
1054 state := details.State()
1055 for _, id := range state.IDs() {
1056 value, found := state.Value(id)
1057 if !found {
1058 continue
1059 }
1060 if _, ok := p.CoverageStats[id]; !ok {
1061 p.CoverageStats[id] = make(set)
1062 }
1063 p.CoverageStats[id][value] = struct{}{}
1064 }
1065 // Propagate visitedness after collecting direct observations
1066 propagateVisitedness(p.Ast, p.CoverageStats, state)
1067}
1068
1069// propagateVisitedness implements two rules for extending the coverage report:
1070// - If a node is visited, all its ancestors are visited.

Callers 1

ExecuteTestMethod · 0.85

Calls 4

propagateVisitednessFunction · 0.85
StateMethod · 0.80
IDsMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected