Skip to content

Commit

Permalink
'genhtml --date-labels string[,string...]' option - to specify label …
Browse files Browse the repository at this point in the history
…for corresponding 'date' table entries in HTML report. (#363)



Signed-off-by: Henry Cox <[email protected]>
  • Loading branch information
henry2cox authored Dec 19, 2024
1 parent 5f3bd92 commit 5bdf2f5
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 13 deletions.
5 changes: 3 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-------------------------------------------------
- README file for the LTP GCOV extension (LCOV) -
- Last changes: 2024-11-26
- Last changes: 2024-12-16
-------------------------------------------------

Description
Expand Down Expand Up @@ -313,7 +313,8 @@ LCOV features and capabilities fall into 7 major categories:

Related options:
--baseline-file, --diff-file, --annotate-script, --select-script
--date-bins, --new-file-as-baseline, --elide-path-mismatch
--date-bins, --date-labels --new-file-as-baseline,
--elide-path-mismatch

b) Error handling

Expand Down
21 changes: 18 additions & 3 deletions bin/genhtml
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,28 @@ sub noBaseline
sub setAgeGroups
{
#my $numGroups = scalar(@_) + 1;
@cutpoints = sort({ $a <=> $b } @_);
@cutpoints = sort({ $a <=> $b } @_);
if (@ageGroupHeader) {
# labels were specified by user
@ageGroupHeader = split($lcovutil::split_char,
join($lcovutil::split_char, @ageGroupHeader));
goto done
if (scalar(@ageGroupHeader) == scalar(@cutpoints) + 1);
# mismatched number - generate warning
lcovutil::ignorable_error($lcovutil::ERROR_USAGE,
"expected number of 'age' labels to match 'date-bin' cutpoints");
# if message ignored, then assign default labels
}
@ageGroupHeader = ();
%ageHeaderToBin = ();
my $prefix = "[..";
foreach my $days (@cutpoints) {
my $header = $prefix . $days . "] days";
push(@ageGroupHeader, $header);
$prefix = "(" . $days . ",";
}
push(@ageGroupHeader, "(" . $cutpoints[-1] . "..) days");
done:
%ageHeaderToBin = ();
my $bin = 0;
foreach my $header (@ageGroupHeader) {
$ageHeaderToBin{$header} = $bin;
Expand Down Expand Up @@ -6851,7 +6863,7 @@ STDERR->autoflush;
STDOUT->autoflush;

my @datebins;
my (@rc_date_bins, @rc_annotate_script, @rc_select_script);
my (@rc_date_bins, @rc_annotate_script, @rc_select_script, @rc_date_labels);

my %genhtml_rc_opts = (
"genhtml_css_file" => \$css_filename,
Expand Down Expand Up @@ -6909,6 +6921,7 @@ my %genhtml_rc_opts = (
"select_script" => \@rc_select_script,
'num_context_lines' => \$InInterestingRegion::num_context_lines,
'genhtml_date_bins' => \@rc_date_bins,
'genhtml_date_labels' => \@rc_date_labels,
'truncate_owner_table' => \@truncateOwnerTableLevels,
'owner_table_entries' => \$ownerTableElements,
'compact_summary_tables' => \$compactSummaryTables,
Expand Down Expand Up @@ -6944,6 +6957,7 @@ my %genhtml_options = ("output-directory|o=s" => \$output_directory,
'show-zero-columns' => \$show_zeroTlaColumns,
'simplified-colors' => \$show_simplifiedColors,
"date-bins=s" => \@datebins,
'date-labels=s' => \@SummaryInfo::ageGroupHeader,
"prefix|p=s" => \@opt_dir_prefix,
"num-spaces=i" => \$tab_size,
"no-prefix" => \$no_prefix,
Expand Down Expand Up @@ -7003,6 +7017,7 @@ $mcdc_med_limit = $med_limit if (!defined($mcdc_med_limit));
$frames = undef unless (defined($frames) && $frames);

foreach my $rc ([\@datebins, \@rc_date_bins],
[\@SummaryInfo::ageGroupHeader, \@rc_date_labels],
[\@SourceFile::annotateScript, \@rc_annotate_script],
[\@selectCallbackScript, \@rc_select_script]

Expand Down
6 changes: 2 additions & 4 deletions bin/geninfo
Original file line number Diff line number Diff line change
Expand Up @@ -1905,12 +1905,10 @@ sub process_dafile($$$$)
);
if ($lcovutil::opt_adjust_unexecuted_blocks) {
$hit = 0;
} elsif (
lcovutil::warn_once(
} elsif (lcovutil::warn_once(
"unexecuted block",
$ERROR_INCONSISTENT_DATA
)
) {
)) {
lcovutil::ignorable_warning(
$ERROR_INCONSISTENT_DATA,
"$source_filename:$line_number: unexecuted block on non-branch line with non-zero hit count. Use \"geninfo --rc geninfo_unexecuted_blocks=1 to set count to zero."
Expand Down
37 changes: 36 additions & 1 deletion man/genhtml.1
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ genhtml \- Generate HTML view from LCOV coverage data files
.RB [ \-\-date\-bins
.IR day[,day,...]]
.br
.RB [ \-\-date\-labels
.IR string[,string,...]]
.br
.RB [ \-\-show\-owners
.IR [ all ] ]
.br
Expand Down Expand Up @@ -1937,7 +1940,39 @@ for details.
.RS
The
.B \-\-date\-bins
option is used to specify age boundaries (cutpoints) for date\-binning classification. If not specified, the default is to use 4 age ranges: less than 7 days, 7 to 30 days, 30 to 180 days, and more than 180 days.
option is used to specify age boundaries (cutpoints) for date\-binning classification. Each
.I age
element is expected to be an integer number of days prior to today (or SOURCE_DATE_EPOCH, if specified). If not specified, the default is to use 4 age ranges: less than 7 days, 7 to 30 days, 30 to 180 days, and more than 180 days.
This option is equivalent to the
.I genhtml_date_bins
config file option. See man
.B lcovrc(5).

This argument has no effect if there is no
.I source\-annotation\-script .

.RE
.BI "\-\-date\-labels " string[,string,...]
.RS
The
.B \-\-date\-labels
option is used to specify labels used for the 'date\-bin' table entries in the HTML report.
.br
The number of labels should be one greater than the number of cutpoints.
.br
If not specified, the default is to use label strings which specify the
.I [from ..to)
range of ages held by the corresponding bin.

One possible use of this option is to use release names in the tables -
.I i.e.,
to indicate the release in which each particular line first appeared.

This option is equivalent to the
.I genhtml_date_labels
config file option. See man
.B lcovrc(5).

This argument has no effect if there is no
.I source\-annotation\-script .

Expand Down
18 changes: 16 additions & 2 deletions man/lcovrc.5
Original file line number Diff line number Diff line change
Expand Up @@ -2647,10 +2647,24 @@ The default is 20.
.IR integer[,integer..]
.IP
This option is equivalent to the "genhtml \-\-date\-bins" option.
See the genhtml man page for details.
See man
.B genhtml(1)
for details.

This option can be used multiple times in the lcovrc file to set multiple cutpoints.
The cutpoints specified in the lcovrc file are appended to the cutpoints (if any) specified on the command line.

.PP

.BR genhtml_datelabels " ="
.IR string[,string..]
.IP
This option is equivalent to the "genhtml \-\-date\-labels" option.
See man
.B genhtml(1)
for details.

This option can be used multiple times in the lcovrc file to set multiple labels.
The number of labels should equal one greater than number of cutpoints.

.PP

Expand Down
18 changes: 17 additions & 1 deletion tests/gendiffcov/errs/msgtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ LCOV_OPTS="$LCOV_BASE"
DIFFCOV_OPTS="--filter line,branch,function --function-coverage --branch-coverage --demangle-cpp --prefix $PARENT_VERSION $PROFILE "

rm -f test.cpp *.gcno *.gcda a.out *.info *.log *.json diff.txt
rm -rf select criteria annotate empty unused_src scriptErr scriptFixed epoch inconsistent highlight etc mycache cacheFail expect subset context
rm -rf select criteria annotate empty unused_src scriptErr scriptFixed epoch inconsistent highlight etc mycache cacheFail expect subset context labels

if [ "x$COVER" != 'x' ] && [ 0 != $LOCAL_COVERAGE ] ; then
cover -delete
Expand Down Expand Up @@ -787,6 +787,22 @@ if [ 0 != $? ] ; then
fi
fi
# generate error for case that number of date labels doesn't match
$COVER $GENHTML_TOOL $DIFFCOV_OPTS initial.info -o labels --annotate $ANNOTATE_SCRIPT --baseline-file initial.info --title 'context' --header-title 'this is the header' --date-bins 1,5,22 --date-labels a,b,c,d,e --baseline-date "$NOW" --msg-log labels.log
if [ 0 == $? ] ; then
echo "ERROR: genhtml --date-labels didn't fail"
if [ 0 == $KEEP_GOING ] ; then
exit 1
fi
fi
grep -E "ERROR: .*usage.* expected number of 'age' labels to match" labels.log
if [ 0 != $? ] ; then
echo "ERROR: didn't find expected labels message"
if [ 0 == $KEEP_GOING ] ; then
exit 1
fi
fi
if [ "$ENABLE_MCDC" != 1 ] ; then
$COVER $GENINFO_TOOL . -o mccd --mcdc-coverage $LCOV_OPTS --msg-log mcdc_errs.log
if [ 0 == $? ] ; then
Expand Down

0 comments on commit 5bdf2f5

Please sign in to comment.