linux-test-project / lcov

LCOV
GNU General Public License v2.0
867 stars 235 forks source link

[flutter][lcov][--remove] branch coverage missing when remove the special file partterns #225

Closed LongXiangGuo closed 1 year ago

LongXiangGuo commented 1 year ago

ENV: Flutter version 3.7.12 LCOV version 2.1-beta

Expected result:

When remove the special file patterns from the generated lcvo.info, the branch coverage could generated by the lcov --branch-coverage --summary command. test data: coverage.zip

Actual Result:

Branch coverage could not generated by the lcov --branch-coverage --summary command when remove the special file patterns.

When remove the special file patterns from the lcov.info, could not summary the branch coverage from the lcov.info

Attempting alternative solutions

The subcommand --exclude PATTERN of lcov and genhtml only support single file pattens, how to exclude those file patterns with the lcov|genhtml --exclude command? I have tried use the | to connect them but it failed.

lcov --remove coverage/lcov.info '**/models/*.dart' -o coverage/lcov.info --ignore-errors=unused,empty
lcov --remove coverage/lcov.info '*_constants.dart' -o coverage/lcov.info --ignore-errors=unused,empty
lcov --remove coverage/lcov.info '*_wrapper.dart' -o coverage/lcov.info --ignore-errors=unused,empty
lcov --remove coverage/lcov.info '*.g.dart' -o coverage/lcov.info --ignore-errors=unused,empty
oberpar commented 1 year ago

When processing LCOV coverage files, make sure that each invocation of lcov/geninfo/genhtmlis configured to keep branch coverage data. Otherwise it will be removed.

The easiest way to achieve this is by creating an lcovrc file in either ~/.lcovrc or /etc/lcovrc with the following contents:

$ cat ~/.lcovrc
branch_coverage=1

Alternatively you need to specify --branch-coverage on all invocations of lcov. Also multiple remove patterns can be given to lcovby simply listing them on the command line. For your example, the following should work:

$ lcov --branch-coverage --remove coverage/lcov.info '**/models/*.dart'  '*_constants.dart' '*_wrapper.dart' '*.g.dart' -o coverage/lcov.info --ignore-errors=unused,empty
LongXiangGuo commented 1 year ago

Thanks, I didn't realize that all the commands related to LCOV need to be tried with --branch-coverage.

henry2cox commented 1 year ago

Thanks, I didn't realize that all the commands related to LCOV need to be tried with --branch-coverage.

Should say so in the man pages. I'll check and see if this is clear - though I suspect that it is not, as your problem seems to be a fairly common one.

Henry

henry2cox commented 1 year ago

I forgot to add to Peter's comment:

The easiest way to achieve this is by creating an lcovrc file in either ~/.lcovrc or /etc/lcovrc

If you always want to ignore 'unused' and 'empty' error categories, then you can add those directives to your lcovrc file as well. man page describes the syntax.

LongXiangGuo commented 1 year ago

There is no man. page for lcov No manual entry for lcov for Mac OS 13.3.1 (a) (22E772610a)

 man lcov
No manual entry for lcov
henry2cox commented 1 year ago

That sounds like an install issue. There are definitely man pages for the various lcov components. Where is your lcov script found, and what is your MANPATH?

$ which lcov $ echo $MANPATH

The other question is where you got your lcov version and how you installed it.

LongXiangGuo commented 1 year ago

Thanks, I see, the lcov locate in the lcov git repo, refer to the master for the latest fix , and the $MAINPATH is not set locally, because I did't use run the make install command in the git repo, just export the bin path. After local installed the main page displayed.