Skip to content

Commit 5f3bd92

Browse files
authored
'lcov --capture' interface change: apply 'region' and 'branch_region' 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]>
1 parent b231a5e commit 5f3bd92

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

bin/geninfo

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,21 @@ if ($lcovutil::mcdc_coverage) {
427427
# Determine compatibility modes
428428
parse_compat_modes($lcovutil::geninfo_opt_compat);
429429

430-
unless ($no_markers) {
430+
if ($no_markers) {
431+
lcovutil::ignorable_error($lcovutil::ERROR_USAGE,
432+
"use new '--filter' option or old '--no-markers' - not both")
433+
if (@lcovutil::opt_filter);
434+
} elsif (!@lcovutil::opt_filter) {
435+
# don't apply the backward-compatible options if user specifies any filters
436+
lcovutil::info(1,
437+
"$lcovutil::tool_name: applying '--filter region,branch_region' by default - see the '--no-markers' section in the man page for more information.\n"
438+
);
431439
push(@lcovutil::opt_filter, "region");
432440
push(@lcovutil::opt_filter, "branch_region") if $br_coverage;
441+
} else {
442+
lcovutil::info(
443+
"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"
444+
) unless grep({ /(region|branch_region)/ } @lcovutil::opt_filter);
433445
}
434446
parse_cov_filters(@lcovutil::opt_filter);
435447

man/geninfo.1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,8 +1135,24 @@ entry in
11351135
.B \-\-no\-markers
11361136
.br
11371137
.RS
1138+
Unless the
1139+
.I \-\-no\-markers
1140+
option is used,
1141+
.BR geninfo
1142+
will apply both
1143+
.I region
1144+
and
1145+
.I branch_region
1146+
filters to the captured coverae data.
11381147
Use this option if you want to get coverage data without regard to exclusion
11391148
markers in the source code file.
1149+
1150+
If any
1151+
.I \-\-filter
1152+
options are applied, then the default region filters are not used.
1153+
1154+
.I \-\-no\-markers should not be specified along with
1155+
.I \-\-filter.
11401156
.RE
11411157

11421158
.B \-\-no\-recursion

tests/gendiffcov/errs/msgtest.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,23 @@ if [ 0 != $? ] ; then
285285
fi
286286
fi
287287
288+
echo geninfo $LCOV_OPTS --no-markers --filter branch . -o usage1.info --msg-log markers.err
289+
$GENINFO_TOOL $LCOV_OPTS --no-markers --filter branch . -o usage1.info --msg-log markers.err
290+
if [ 0 == $? ] ; then
291+
echo "ERROR: expected usage error"
292+
if [ 0 == $KEEP_GOING ] ; then
293+
exit 1
294+
fi
295+
fi
296+
grep "use new '--filter' option or old" markers.err
297+
if [ 0 != $? ] ; then
298+
echo "ERROR: didint find usage error"
299+
if [ 0 == $KEEP_GOING ] ; then
300+
exit 1
301+
fi
302+
fi
303+
304+
288305
echo lcov $LCOV_OPTS --summary initial.info --config-file noSuchFile --ignore usage
289306
$COVER $LCOV_TOOL $LCOV_OPTS --summary initial.info --config-file noSuchFile --ignore usgae 2>&1 | tee err_missing.log
290307
grep "cannot read configuration file 'noSuchFile'" err_missing.log

0 commit comments

Comments
 (0)