MCPcopy Index your code
hub / github.com/evalplus/evalplus / parse_lcov

Function parse_lcov

tools/tsr/coverage_init.py:27–47  ·  view source on GitHub ↗
(outputs: List[str])

Source from the content-addressed store, hash-verified

25
26
27def parse_lcov(outputs: List[str]):
28 switch, extracted_outputs = False, []
29 for line in outputs:
30 if switch == False and "tmp_src" in line:
31 switch = True
32 if switch == True and "end_of_record" in line:
33 switch = False
34 if switch:
35 extracted_outputs.append(line)
36
37 branch, branch_covered = [], []
38 for line in extracted_outputs:
39 if line.startswith("BRDA"):
40 # BRDA format: BR:<lineno>,<blockno>,<branchno>,<taken>
41 lineno, blockno, branchno, taken = line[5:].split(",")
42 branch_sig = f"BR:{lineno},{blockno},{branchno}"
43 branch.append(branch_sig)
44 if taken not in ["0", "-"]:
45 branch_covered.append(branch_sig)
46 per = 1.0 if len(branch) == 0 else len(branch_covered) / len(branch)
47 return per, branch, branch_covered
48
49
50def test_code_coverage(

Callers 1

test_code_coverageFunction · 0.70

Calls

no outgoing calls

Tested by 1

test_code_coverageFunction · 0.56