Skip to content

Commit 417448c

Browse files
committed
Change message category to 'internal' - for certain errors which
can happen only if there is an implementation bug (not a user error or data inconsistency) Signed-off-by: Henry Cox <[email protected]>
1 parent 3b15bf5 commit 417448c

File tree

2 files changed

+54
-26
lines changed

2 files changed

+54
-26
lines changed

bin/genhtml

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ use File::Copy;
8282
use File::Path;
8383
use File::Spec;
8484
use File::Temp;
85+
use Scalar::Util qw/looks_like_number/;
8586
use Digest::MD5 qw(md5_base64);
8687
use Cwd qw/abs_path realpath cwd/;
8788
use DateTime;
@@ -981,11 +982,13 @@ sub branchCovCount
981982
if ($group eq "age") {
982983
my $a = $branch->[AGE];
983984
my $bin = SummaryInfo::findAgeBin($age);
985+
# LCOV_EXCL_START
984986
unless (exists($a->[$bin]) && exists($a->[$bin]->{$key})) {
985-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
987+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
986988
"unexpected key '$key' for bin '$bin'");
987989
return;
988990
}
991+
# LCOV_EXCL_STOP
989992
$a->[$bin]->{$key} += $delta;
990993
return $a->[$bin]->{$key};
991994
}
@@ -1015,11 +1018,13 @@ sub functionCovCount
10151018
if ($group eq "age") {
10161019
my $a = $func->[AGE];
10171020
my $bin = SummaryInfo::findAgeBin($age);
1021+
# LCOV_EXCL_START
10181022
unless (exists($a->[$bin]) && exists($a->[$bin]->{$key})) {
1019-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
1023+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
10201024
"unexpected key '$key' for bin '$bin'");
10211025
return;
10221026
}
1027+
# LCOV_EXCL_STOP
10231028
$a->[$bin]->{$key} += $delta;
10241029
return $a->[$bin]->{$key};
10251030
}
@@ -2242,11 +2247,12 @@ sub _mergeBranchData
22422247

22432248
my $current = $branch->[$loc];
22442249
foreach my $branchId ($current->blocks()) {
2250+
# LCOV_EXCL_START
22452251
if (!$branchData->hasBlock($branchId)) {
22462252
# don't know how to get here...but someone on the internet
22472253
# managed to do it - so we need to handle the error
22482254
my $which = $loc == DATA_BASELINE ? 'baseline' : 'current';
2249-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2255+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
22502256
$filename . ':' . $current->line() .
22512257
": '$which' line " .
22522258
$self->lineNo($which) .
@@ -2256,21 +2262,24 @@ sub _mergeBranchData
22562262
);
22572263
next;
22582264
}
2265+
# LCOV_EXCL_STOP
22592266

22602267
my $c = $current->getBlock($branchId);
22612268
my $d = $branchData->getBlock($branchId);
22622269
# handle case of inconsistent branch data
22632270
my $nc = scalar(@$c);
22642271
my $nd = scalar(@$d);
2272+
# LCOV_EXCL_START
22652273
if ($nc != $nd) {
22662274
# similarly: this should not happen - but it might
22672275
my $which = $loc == DATA_BASELINE ? 'baseline' : 'current';
2268-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2276+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
22692277
$filename . ':' . $current->line() .
22702278
": '$which' line " . $self->lineNo($which) .
22712279
" branch $branchId contains $nc elements but merge data contains $nd."
22722280
);
22732281
}
2282+
# LCOV_EXCL_STOP
22742283
for (my $i = ($nc > $nd ? $nd : $nc) - 1; $i >= 0; --$i) {
22752284
my $br = $d->[$i];
22762285
$c->[$i]->merge($br);
@@ -2680,12 +2689,14 @@ sub _categorizeBranchCov
26802689
# a high probability event?
26812690
foreach my $line ($branchCurrent->keylist()) {
26822691
my $type = $linemap->type($filename, $linemap->NEW, $line);
2692+
# LCOV_EXCL_START
26832693
if ($type eq 'delete') {
2684-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2694+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
26852695
"'current' line $filename:$line should not be marked 'delete'");
26862696
delete($branchCurrent->{$line});
26872697
next;
26882698
}
2699+
# LCOV_EXCL_STOP
26892700
my $data;
26902701
if (!exists($lineDataMap->{$line})) {
26912702
# we expect the associated line to also have line coverage data
@@ -2735,9 +2746,10 @@ sub _categorizeBranchCov
27352746
my @baseBlocks = defined($base) ? $base->blocks() : ();
27362747

27372748
if ($type eq 'insert') {
2738-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2749+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
27392750
"baseline branch data should not be defined for inserted line $filename:$line"
27402751
) if defined($base);
2752+
27412753
foreach my $branchId (@currBlocks) {
27422754
my $block = $categorized->addBlock($branchId);
27432755
foreach my $br (@{$curr->getBlock($branchId)}) {
@@ -2747,9 +2759,10 @@ sub _categorizeBranchCov
27472759
}
27482760
}
27492761
} elsif ($type eq 'delete') {
2750-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2762+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
27512763
"current branch data should not be defined for deleted line $filename:$line"
27522764
) if defined($curr);
2765+
27532766
foreach my $branchId (@baseBlocks) {
27542767
my $block = $categorized->addBlock($branchId);
27552768
foreach my $br (@{$base->getBlock($branchId)}) {
@@ -2759,7 +2772,7 @@ sub _categorizeBranchCov
27592772
}
27602773
}
27612774
} else {
2762-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2775+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
27632776
"unexpected branch coverage type $type at $filename:$line")
27642777
if $type ne 'equal';
27652778

@@ -2848,17 +2861,16 @@ sub _categorizeFunctionCov
28482861
my $line = $func->line();
28492862
my $type = $linemap->type($filename, $linemap->NEW, $line);
28502863
$funcCovLines{$line} = 1;
2851-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2864+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
28522865
"'current' line $filename:$line should not be marked 'delete'")
28532866
if $type eq 'delete';
2854-
28552867
my $data;
28562868
if (!exists($lineDataMap->{$line})) {
28572869
$data = LineData->new($type);
28582870
$lineDataMap->{$line} = $data;
28592871
} else {
28602872
$data = $lineDataMap->{$line};
2861-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2873+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
28622874
"type mismatch " . $data->type() .
28632875
" -> $type for $filename:$line")
28642876
unless $data->type() eq $type;
@@ -2904,7 +2916,7 @@ sub _categorizeFunctionCov
29042916
if (!defined($base)) {
29052917
# either this line was inserted or the line hasn't changed but
29062918
# wasn't recognized as a function before (e.g., unused template)
2907-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2919+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
29082920
"unexpected undef baseline function data for deleted $filename:$line"
29092921
) if $type eq 'delete';
29102922
my $hit = $curr->hit();
@@ -2919,7 +2931,7 @@ sub _categorizeFunctionCov
29192931
$categorized->addAliasDifferential($alias, [$hit, $tla]);
29202932
}
29212933
} elsif (!defined($curr)) {
2922-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2934+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
29232935
"unexpected undef current function data for inserted $filename:$line"
29242936
) if $type eq 'insert';
29252937
my $hit = $base->hit();
@@ -2934,7 +2946,7 @@ sub _categorizeFunctionCov
29342946
$categorized->addAliasDifferential($alias, [$hit, $tla]);
29352947
}
29362948
} else {
2937-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
2949+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
29382950
"unexpected function coverage type $type at $filename:$line")
29392951
if $type ne 'equal';
29402952
# if we know end lines for this function, then check if there
@@ -3422,14 +3434,15 @@ sub _read_udiff
34223434
);
34233435
last;
34243436
}
3437+
# LCOV_EXCL_START
34253438
if (exists($self->[LINEMAP]->{$key})) {
3426-
lcovutil::ignorable_error(
3427-
$lcovutil::ERROR_INCONSISTENT_DATA,
3439+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
34283440
"$diff_file:$.: $key 'unchanged' entry found but diff records exist"
34293441
. ($file eq $key ? '' : " (substituted '$file')"));
34303442
# message ignored - delete the diff records
34313443
delete($self->[LINEMAP]->{$key});
34323444
}
3445+
# LCOV_EXCL_STOP
34333446
$self->[UNCHANGED]->{$key} = 1;
34343447
last;
34353448
};
@@ -3467,16 +3480,18 @@ sub _read_udiff
34673480
$filename = $notNull ? $key : undef;
34683481

34693482
if ($filename) {
3483+
# LCOV_EXCL_START
34703484
if (exists($self->[UNCHANGED]->{$key})) {
34713485
lcovutil::ignorable_error(
3472-
$lcovutil::ERROR_INCONSISTENT_DATA,
3486+
$lcovutil::ERROR_INTERNAL,
34733487
"$diff_file:$.: $filename marked unchanged but diff record found"
34743488
.
34753489
($file_new eq $key ? '' :
34763490
" (substituted '$file_new')"));
34773491
# OK - error ignored...remove the 'unchanged' marker
34783492
delete($self->[UNCHANGED]->{$key});
34793493
}
3494+
# LCOV_EXCL_STOP
34803495
$self->[LINEMAP]->{$key} = [];
34813496
}
34823497
if ($notNull) {
@@ -4031,12 +4046,14 @@ sub _countBranchTlaData
40314046
my $diff = $differentialData->getBlock($branchId);
40324047
foreach my $b (@$diff) {
40334048
my $tla = $b->[1];
4049+
# LCOV_EXCL_START
40344050
unless (defined($tla)) {
4035-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
4051+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
40364052
"undef TLA for branch $branchId of " . $self->path() .
40374053
":$line - lineTLA:$lineTla taken:" . $b->[0]);
40384054
next;
40394055
}
4056+
# LCOV_EXCL_STOP
40404057
$fileSummary->[SummaryInfo::BRANCH_DATA]->[SummaryInfo::DATA]
40414058
->{$tla} += 1;
40424059
# keep track of all the branch TLAs found on this line...
@@ -4197,12 +4214,14 @@ sub _accountFunction
41974214
{
41984215
my ($fileSummary, $tla, $src_age) = @_;
41994216

4217+
# LCOV_EXCL_START
42004218
unless (defined($tla)) {
4201-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
4219+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
42024220
"undef function TLA for age '$src_age' of " .
42034221
$fileSummary->name());
42044222
return 1; # error
42054223
}
4224+
# LCOV_EXCL_STOP
42064225

42074226
$fileSummary->[SummaryInfo::FUNCTION_DATA]->[SummaryInfo::DATA]->{$tla} +=
42084227
1;
@@ -4230,8 +4249,9 @@ sub _countFunctionTlaData
42304249
defined($lcovutil::cov_filter[$lcovutil::FILTER_FUNCTION_ALIAS]);
42314250
my $h = $func->hit();
42324251
my $mergedTla = $h->[1];
4252+
# LCOV_EXCL_START
42334253
if (!defined($mergedTla)) {
4234-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
4254+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
42354255
"undef TLA for function '" . $func->name() .
42364256
"' hit " . $h->[0] . " at line " .
42374257
$line . " (" . $lineData->tla() .
@@ -4242,6 +4262,7 @@ sub _countFunctionTlaData
42424262
$h->[1] = $mergedTla;
42434263
#return;
42444264
}
4265+
# LCOV_EXCL_STOP
42454266

42464267
if (!grep(/^$mergedTla$/, ('DUB', 'DCB'))) {
42474268
# deleted lines don't have owner data...
@@ -4262,8 +4283,9 @@ sub _countFunctionTlaData
42624283
foreach my $alias (keys %$aliases) {
42634284
my $data = $aliases->{$alias};
42644285
my $tla = $data->[1];
4286+
# LCOV_EXCL_START
42654287
if (!defined($tla)) {
4266-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
4288+
lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL,
42674289
"undef TLA for alias:'$alias' hit:" .
42684290
$data->[0] . " of function '" . $func->name() .
42694291
"' hit " . $h->[0] . " at line " . $line . " (" .
@@ -4272,6 +4294,7 @@ sub _countFunctionTlaData
42724294
$tla = $data->[0] == 0 ? 'UNC' : 'GNC';
42734295
$data->[1] = $tla;
42744296
}
4297+
# LCOV_EXCL_STOP
42754298
_accountFunction($fileSummary, $tla, $src_age);
42764299
}
42774300
}
@@ -5529,9 +5552,13 @@ sub merge_child($$$)
55295552
my $name =
55305553
$childSummary->type() eq 'top' ? "" : $childSummary->name();
55315554
$SummaryInfo::coverageCriteria{$name} = $criteria;
5532-
$SummaryInfo::coverageCriteriaStatus = $criteria->[1]
5533-
if ($criteria->[1] != 0 ||
5534-
0 != scalar(@{$criteria->[2]}));
5555+
$criteria->[1] = 0 if $criteria->[1] eq '';
5556+
my $v = $criteria->[1];
5557+
die('unexpected criteria data \'' .
5558+
join(' ', @$criteria) . '\'')
5559+
unless (Scalar::Util::looks_like_number($v));
5560+
$SummaryInfo::coverageCriteriaStatus =
5561+
($v != 0 || 0 != scalar(@{$criteria->[2]})) ? $v : 0;
55355562
}
55365563
};
55375564
if ($@) {
@@ -6099,7 +6126,8 @@ if (0 == $exit_status && @SummaryInfo::coverageCriteriaScript) {
60996126
keys(%SummaryInfo::coverageCriteria))
61006127
) {
61016128
my $criteria = $SummaryInfo::coverageCriteria{$name};
6102-
next if $criteria->[1] == 0 && 0 == scalar(@{$criteria->[2]}); # passed
6129+
my $v = $criteria->[1];
6130+
next if (!$v || $v == 0) && 0 == scalar(@{$criteria->[2]}); # passed
61036131

61046132
my $msg = $criteria->[0];
61056133
if ($criteria->[0] ne 'top') {

tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ report:
2323
$(SPREADSHEET_TOOL) -o report.xlsx `find . -name "*.json"`
2424
if [ "x$(COVERAGE)" != 'x' ] ; then \
2525
cover $(COVER_DB) ; \
26-
$(BINDIR)/perl2lcov -o perlcov.info $(COVER_DB) --version-script $(VERSION_SCRIPT) --exclude 'filter.pl' --ignore unsupported ; \
26+
$(BINDIR)/perl2lcov -o perlcov.info $(COVER_DB) --version-script $(VERSION_SCRIPT) --exclude 'genError.pm' --exclude 'filter.pl' --omit-lines 'ERROR_INTERNAL' --omit-lines '\bdie\b' --ignore unsupported --filter region ; \
2727
if [ -f $(PYCOV_DB) ] ; then \
2828
$(BINDIR)/py2lcov -o pycov.info $(PYCOV_DB) --version-script $(VERSION_SCRIPT) ; \
2929
fi ; \

0 commit comments

Comments
 (0)