davglass / lcov-parse

Simple LCOV file parser
Other
53 stars 13 forks source link

Parser fails when no branches are encountered. #3

Closed bigeasy closed 11 years ago

bigeasy commented 11 years ago

When a file contains no branches the lcov report will contain no BRDA record, but it will still have a BRF and BRH record. The lcov-parse creates a branches property when a BRDA is encountered, updates the branches record with a summary when the BRF is encountered. If no BRDA record is encountered an error occurs when the BRF is encountered and the summary data is written to a branches property that does not exist.

Example lcov file for javascript/common.js in the project Stencil.

TN:
SF:javascript/common.js
FN:2,create
FN:3,javascript
FNF:2
FNH:2
FNDA:19,create
FNDA:2,javascript
DA:1,19
DA:2,19
DA:3,19
DA:4,2
DA:5,2
DA:7,0
LF:6
LH:5
BRF:0
BRH:0
end_of_record

Meaningful file with no branches; try/catch is not considered a branch.

bigeasy commented 11 years ago

Okay. It might be an error to have a BRF if there is no BRDA. This is output from Istanbul. The issue https://github.com/gotwarlost/istanbul/issues/20 references how Istanbul emits summaries in lcov.

I've forked and created a patch, but I see that your first test does not have branches, but also has no summaries. I assume that you got output from a working JavaScript coverage program, so the bug might be in Istanbul.