Skip to content

Commit

Permalink
'lcov --capture' interface change: apply 'region' and 'branch_region'…
Browse files Browse the repository at this point in the history
… default filters only if '--filter ...' option was not used. (#362)

Error if both '--filter' and '--no-markers' are specified (or or the other - not both).
Action is unchanged (filter out excluded regions) if no filter options are specified.

Signed-off-by: Henry Cox <[email protected]>
  • Loading branch information
henry2cox authored Dec 19, 2024
1 parent b231a5e commit 5f3bd92
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bin/geninfo
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,21 @@ if ($lcovutil::mcdc_coverage) {
# Determine compatibility modes
parse_compat_modes($lcovutil::geninfo_opt_compat);

unless ($no_markers) {
if ($no_markers) {
lcovutil::ignorable_error($lcovutil::ERROR_USAGE,
"use new '--filter' option or old '--no-markers' - not both")
if (@lcovutil::opt_filter);
} elsif (!@lcovutil::opt_filter) {
# don't apply the backward-compatible options if user specifies any filters
lcovutil::info(1,
"$lcovutil::tool_name: applying '--filter region,branch_region' by default - see the '--no-markers' section in the man page for more information.\n"
);
push(@lcovutil::opt_filter, "region");
push(@lcovutil::opt_filter, "branch_region") if $br_coverage;
} else {
lcovutil::info(
"Note: 'region' and 'branch_region' filters are not applied by default when '--filter' is specified. See the '--no-markers section in the man page for more information.\n"
) unless grep({ /(region|branch_region)/ } @lcovutil::opt_filter);
}
parse_cov_filters(@lcovutil::opt_filter);

Expand Down
16 changes: 16 additions & 0 deletions man/geninfo.1
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,24 @@ entry in
.B \-\-no\-markers
.br
.RS
Unless the
.I \-\-no\-markers
option is used,
.BR geninfo
will apply both
.I region
and
.I branch_region
filters to the captured coverae data.
Use this option if you want to get coverage data without regard to exclusion
markers in the source code file.

If any
.I \-\-filter
options are applied, then the default region filters are not used.

.I \-\-no\-markers should not be specified along with
.I \-\-filter.
.RE

.B \-\-no\-recursion
Expand Down
17 changes: 17 additions & 0 deletions tests/gendiffcov/errs/msgtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,23 @@ if [ 0 != $? ] ; then
fi
fi
echo geninfo $LCOV_OPTS --no-markers --filter branch . -o usage1.info --msg-log markers.err
$GENINFO_TOOL $LCOV_OPTS --no-markers --filter branch . -o usage1.info --msg-log markers.err
if [ 0 == $? ] ; then
echo "ERROR: expected usage error"
if [ 0 == $KEEP_GOING ] ; then
exit 1
fi
fi
grep "use new '--filter' option or old" markers.err
if [ 0 != $? ] ; then
echo "ERROR: didint find usage error"
if [ 0 == $KEEP_GOING ] ; then
exit 1
fi
fi
echo lcov $LCOV_OPTS --summary initial.info --config-file noSuchFile --ignore usage
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --config-file noSuchFile --ignore usgae 2>&1 | tee err_missing.log
grep "cannot read configuration file 'noSuchFile'" err_missing.log
Expand Down

0 comments on commit 5f3bd92

Please sign in to comment.