Skip to content

Commit 22e52b2

Browse files
committed
Add tests for various error conditions.
Fix issues exposed by those tests. Signed-off-by: Henry Cox <[email protected]>
1 parent 6614e46 commit 22e52b2

File tree

17 files changed

+769
-103
lines changed

17 files changed

+769
-103
lines changed

bin/genhtml

Lines changed: 85 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,7 @@ sub get
666666
if !defined($type);
667667

668668
my $hash = $self->[$type]->[DATA];
669-
if ($key eq "total") {
670-
return $hash->{found};
671-
} elsif ($key eq "missed") {
669+
if ($key eq "missed") {
672670
my $missed = 0;
673671
foreach my $k ('UBC', 'UNC', 'UIC', 'LBC') {
674672
$missed += $hash->{$k}
@@ -766,8 +764,7 @@ sub owner_tlaCount
766764
return $hash->{$tla}
767765
if (exists($hash->{$tla}));
768766

769-
if ($tla eq "total" ||
770-
$tla eq "found") {
767+
if ($tla eq "found") {
771768
my $total = 0;
772769
foreach my $k (keys(%$hash)) {
773770
# count only code that can be hit (ie., not excluded)
@@ -943,15 +940,12 @@ sub lineCovCount
943940

944941
$delta = 0 unless defined($delta);
945942

946-
if ($key eq 'total') {
947-
$key = 'found';
948-
} elsif ($key eq 'missed') {
943+
if ($key eq 'missed') {
949944
my $found = $self->lineCovCount('found', $group, $age);
950945
my $hit = $self->lineCovCount('hit', $group, $age);
951946
return $found - $hit;
952947
}
953948

954-
$key = 'found' if $key eq 'total';
955949
if ($group eq "age") {
956950
my $a = $self->[LINE_DATA]->[AGE];
957951
my $bin = SummaryInfo::findAgeBin($age);
@@ -977,9 +971,7 @@ sub branchCovCount
977971

978972
$delta = 0 unless defined($delta);
979973

980-
if ($key eq 'total') {
981-
$key = 'found';
982-
} elsif ($key eq 'missed') {
974+
if ($key eq 'missed') {
983975
my $found = $self->branchCovCount('found', $group, $age);
984976
my $hit = $self->branchCovCount('hit', $group, $age);
985977
return $found - $hit;
@@ -1013,9 +1005,7 @@ sub functionCovCount
10131005

10141006
$delta = 0 unless defined($delta);
10151007

1016-
if ($key eq 'total') {
1017-
$key = 'found';
1018-
} elsif ($key eq 'missed') {
1008+
if ($key eq 'missed') {
10191009
my $found = $self->functionCovCount('found', $group, $age);
10201010
my $hit = $self->functionCovCount('hit', $group, $age);
10211011
return $found - $hit;
@@ -1135,6 +1125,18 @@ sub b_hit
11351125
return $b->{hit};
11361126
}
11371127

1128+
sub selected
1129+
{
1130+
my $rtn;
1131+
eval { $rtn = $selectCallback->select(@_); };
1132+
if ($@) {
1133+
$rtn = 1; # return everything
1134+
lcovutil::ignorable_error($lcovutil::ERROR_CALLBACK,
1135+
"select(..) failed: $@");
1136+
}
1137+
return $rtn;
1138+
}
1139+
11381140
sub checkCoverageCriteria
11391141
{
11401142
my $self = shift;
@@ -2076,7 +2078,7 @@ use constant {
20762078
LINE_BASELINE => 1,
20772079
LINE_CURRENT => 2,
20782080

2079-
# data elements for branchfunction data
2081+
# data elements for branch/function data
20802082
DATA_BASELINE => 0,
20812083
DATA_CURRENT => 1,
20822084
DATA_DIFFERENTIAL => 2,
@@ -2099,6 +2101,46 @@ sub new
20992101
return $self;
21002102
}
21012103

2104+
sub to_list
2105+
{
2106+
# used by script-leve 'select' callback
2107+
my $self = shift;
2108+
2109+
my @rtn = ($self->[TYPE],
2110+
[$self->tla(),
2111+
$self->in_curr() ? $self->curr_count() : undef,
2112+
$self->in_base() ? $self->base_count() : undef
2113+
]);
2114+
my $branch = $self->differential_branch();
2115+
if (defined($branch)) {
2116+
my @data;
2117+
push(@rtn, \@data);
2118+
foreach my $block ($branch->blocks()) {
2119+
my $br = $branch->getBlock($block);
2120+
my @b;
2121+
push(@data, \@b);
2122+
foreach my $b (@$br) {
2123+
my ($br, $tla, $d) = @$b;
2124+
my ($base_count, $curr_count) = @$d;
2125+
push(@b, [$tla, $curr_count, $base_count]);
2126+
}
2127+
}
2128+
} else {
2129+
$branch = $self->current_branch();
2130+
if (defined($branch)) {
2131+
my @data;
2132+
push(@rtn, \@data);
2133+
foreach my $block ($branch->blocks()) {
2134+
my $br = $branch->getBlock($block);
2135+
push(@data, $br->count());
2136+
}
2137+
} else {
2138+
push(@rtn, undef);
2139+
}
2140+
}
2141+
return \@rtn;
2142+
}
2143+
21022144
sub tla
21032145
{
21042146
my ($self, $tla) = @_;
@@ -3648,8 +3690,8 @@ sub _computeContextBefore
36483690
my $lineData = $data->{$l} if exists($data->{$l});
36493691
my $annotateData = $annotate->line($l);
36503692
last
3651-
unless $selectCallback->select($lineData, $annotateData,
3652-
$self->[ANNOTATE_OBJ]->path(), $l);
3693+
unless SummaryInfo::selected($lineData, $annotateData,
3694+
$self->[ANNOTATE_OBJ]->path(), $l);
36533695
++$count;
36543696
}
36553697
# region of interest is the (possibly empty) contigous region we found
@@ -3676,7 +3718,7 @@ sub interesting
36763718
my $lineData = $data->{$l} if exists($data->{$l});
36773719
my $annotateData = $annotate->line($l);
36783720
last
3679-
if !$selectCallback->select($lineData, $annotateData,
3721+
if !SummaryInfo::selected($lineData, $annotateData,
36803722
$self->[ANNOTATE_OBJ]->path(), $l);
36813723
++$count;
36823724
}
@@ -3728,6 +3770,17 @@ sub new
37283770
return $self;
37293771
}
37303772

3773+
sub to_list
3774+
{
3775+
# used by 'select' callback - if not a package
3776+
my $self = shift;
3777+
if ($#$self >= OWNER) {
3778+
my @rtn = @{$self}[OWNER, FUNCTION_TLA];
3779+
return \@rtn;
3780+
}
3781+
return undef;
3782+
}
3783+
37313784
sub owner
37323785
{
37333786
my $self = shift;
@@ -3886,8 +3939,8 @@ sub new
38863939
my $annotateData = $self->line($line)
38873940
unless grep(/$tla/, ('DUB', 'DCB'));
38883941
# callback arguments are (LineData, SourceLine)
3889-
if ($selectCallback->select($lne, $annotateData,
3890-
$self->path(), $line)) {
3942+
if (SummaryInfo::selected($lne, $annotateData,
3943+
$self->path(), $line)) {
38913944
push(@lineArray, $line);
38923945
}
38933946
}
@@ -3949,7 +4002,7 @@ sub _countBranchTlaData
39494002
my ($src_age, $developer, $srcLine);
39504003
my $lineTla = $lineData->tla();
39514004
if (@SourceFile::annotateScript &&
3952-
'D' ne substr($lineTla, 0, 1)) {
4005+
!grep(/^$lineTla$/, ('DUB', 'DCB'))) {
39534006
# deleted lines don't have owner data...
39544007
$srcLine = $self->line($line);
39554008
if (!defined($srcLine)) {
@@ -4190,7 +4243,7 @@ sub _countFunctionTlaData
41904243
#return;
41914244
}
41924245

4193-
if ('D' ne substr($mergedTla, 0, 1)) {
4246+
if (!grep(/^$mergedTla$/, ('DUB', 'DCB'))) {
41944247
# deleted lines don't have owner data...
41954248
$srcLine = $self->line($line);
41964249
# info might not be available, if no annotations
@@ -5949,7 +6002,7 @@ if ($no_sourceview && defined($frames)) {
59496002
if ($no_prefix && @dir_prefix) {
59506003
lcovutil::ignorable_warning($lcovutil::ERROR_USAGE,
59516004
"option --prefix disabled because --no-prefix was ignored");
5952-
@dir_prefix = undef;
6005+
@dir_prefix = ();
59536006
}
59546007

59556008
@fileview_sortlist = ($SORT_FILE);
@@ -8606,12 +8659,11 @@ END_OF_HTML
86068659
if (!$main::use_legacyLabels &&
86078660
grep(/^$key$/, ("UNC", "LBC", "UIC")));
86088661

8609-
# want to look in file details to build link to first
8610-
# line...
8662+
# look in file details to build link to first line
86118663
if (!$main::no_sourceview &&
8612-
defined($tableHref) &&
8613-
defined($fileDetails) &&
8614-
'D' ne substr($key, 0, 1) &&
8664+
defined($tableHref) &&
8665+
defined($fileDetails) &&
8666+
!grep(/^$key$/, ('DUB', 'DCB')) &&
86158667
grep(/^$key$/, @SummaryInfo::tlaPriorityOrder)) {
86168668
my $line;
86178669
my $label =
@@ -9786,8 +9838,7 @@ sub buildDateSummaryTable($$$$$$$$$)
97869838
} elsif (!$main::no_sourceview &&
97879839
defined($fileDetail) &&
97889840
defined($nextLocationCallback) &&
9789-
$tla ne 'DCB' &&
9790-
$tla ne 'DUB') {
9841+
!grep(/^$tla$/, ('DUB', 'DCB'))) {
97919842
# no link for deleted lines (DUB, DCB) because there
97929843
# is no TLA for those categories at the location in
97939844
# the 'current' sourceview. That location is just a
@@ -11481,7 +11532,8 @@ END_OF_HTML
1148111532

1148211533
my $funcEntry = $differentialMap->{$func};
1148311534
my ($count, $tla) = @{$funcEntry->hit()};
11484-
next if 'D' eq substr($tla, 0, 1); # don't display deleted functions
11535+
next
11536+
if grep(/^$tla$/, ('DUB', 'DCB')); # don't display deleted functions
1148511537
my $startline = $funcEntry->line() - $func_offset;
1148611538
my $name = $func;
1148711539
my $countstyle;
@@ -11570,8 +11622,7 @@ END_OF_HTML
1157011622
foreach my $alias (@aliasList) {
1157111623
my ($hit, $tla) = @{$aliases->{$alias}};
1157211624
# don't display deleted functions
11573-
next
11574-
if 'D' eq substr($tla, 0, 1);
11625+
next if grep(/^$tla$/, ('DUB', 'DCB')); #
1157511626
my $style = "coverFnAlias" . ($hit == 0 ? "Lo" : "Hi");
1157611627
$tlaRow = "";
1157711628
if ($showTlas) {

bin/geninfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ OPTIONS
678678
--forget-test-names Merge data for all tests names
679679
--version-script SCRIPTNAME Call script to find revision control version
680680
ID of source file
681-
--resolve-script SCRIPTNAME Call script to find source file frpm path
681+
--resolve-script SCRIPTNAME Call script to find source file frpm path
682682
-j, --parallel [N] Use parallel processing with at most N jobs
683683
--memory MB Use at most MB memory in parallel processing
684684
--profile [FILENAME] Write performance statistics to FILENAME

bin/lcov

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,6 @@ if (defined($opt_external)) {
279279

280280
my $begin = Time::HiRes::gettimeofday();
281281

282-
if (!($lcovutil::lcov_capture || @add_tracefile) &&
283-
scalar(@lcovutil::extractVersionScript) > 1) {
284-
foreach my $e (@lcovutil::extractVersionScript) {
285-
$e = "'$e'" if ($e =~ /\s/);
286-
}
287-
lcovutil::ignorable_warning($lcovutil::ERROR_USAGE,
288-
"--version-script ignored except with --capture or --add-tracefile");
289-
}
290-
291282
if ($initial && !$lcovutil::lcov_capture) {
292283
lcovutil::ignorable_warning($lcovutil::ERROR_USAGE,
293284
"'--initial' is ignored except in '--capture' mode.");
@@ -604,7 +595,8 @@ sub check_options()
604595
}
605596

606597
if ($prune_testcases && 0 == scalar(@add_tracefile)) {
607-
die("--prune-tests has effect only when -a/--add-tracefile is specified"
598+
lcovutil::ignorable_error($lcovutil::ERROR_USAGE,
599+
"--prune-tests has effect only when -a/--add-tracefile is specified"
608600
);
609601
}
610602
}

0 commit comments

Comments
 (0)