@@ -82,6 +82,7 @@ use File::Copy;
82
82
use File::Path;
83
83
use File::Spec;
84
84
use File::Temp;
85
+ use Scalar::Util qw/ looks_like_number/ ;
85
86
use Digest::MD5 qw( md5_base64) ;
86
87
use Cwd qw/ abs_path realpath cwd/ ;
87
88
use DateTime;
@@ -981,11 +982,13 @@ sub branchCovCount
981
982
if ($group eq " age" ) {
982
983
my $a = $branch -> [AGE];
983
984
my $bin = SummaryInfo::findAgeBin($age );
985
+ # LCOV_EXCL_START
984
986
unless (exists ($a -> [$bin ]) && exists ($a -> [$bin ]-> {$key })) {
985
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
987
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
986
988
" unexpected key '$key ' for bin '$bin '" );
987
989
return ;
988
990
}
991
+ # LCOV_EXCL_STOP
989
992
$a -> [$bin ]-> {$key } += $delta ;
990
993
return $a -> [$bin ]-> {$key };
991
994
}
@@ -1015,11 +1018,13 @@ sub functionCovCount
1015
1018
if ($group eq " age" ) {
1016
1019
my $a = $func -> [AGE];
1017
1020
my $bin = SummaryInfo::findAgeBin($age );
1021
+ # LCOV_EXCL_START
1018
1022
unless (exists ($a -> [$bin ]) && exists ($a -> [$bin ]-> {$key })) {
1019
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
1023
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
1020
1024
" unexpected key '$key ' for bin '$bin '" );
1021
1025
return ;
1022
1026
}
1027
+ # LCOV_EXCL_STOP
1023
1028
$a -> [$bin ]-> {$key } += $delta ;
1024
1029
return $a -> [$bin ]-> {$key };
1025
1030
}
@@ -2242,11 +2247,12 @@ sub _mergeBranchData
2242
2247
2243
2248
my $current = $branch -> [$loc ];
2244
2249
foreach my $branchId ($current -> blocks()) {
2250
+ # LCOV_EXCL_START
2245
2251
if (!$branchData -> hasBlock($branchId )) {
2246
2252
# don't know how to get here...but someone on the internet
2247
2253
# managed to do it - so we need to handle the error
2248
2254
my $which = $loc == DATA_BASELINE ? ' baseline' : ' current' ;
2249
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2255
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2250
2256
$filename . ' :' . $current -> line() .
2251
2257
" : '$which ' line " .
2252
2258
$self -> lineNo($which ) .
@@ -2256,21 +2262,24 @@ sub _mergeBranchData
2256
2262
);
2257
2263
next ;
2258
2264
}
2265
+ # LCOV_EXCL_STOP
2259
2266
2260
2267
my $c = $current -> getBlock($branchId );
2261
2268
my $d = $branchData -> getBlock($branchId );
2262
2269
# handle case of inconsistent branch data
2263
2270
my $nc = scalar (@$c );
2264
2271
my $nd = scalar (@$d );
2272
+ # LCOV_EXCL_START
2265
2273
if ($nc != $nd ) {
2266
2274
# similarly: this should not happen - but it might
2267
2275
my $which = $loc == DATA_BASELINE ? ' baseline' : ' current' ;
2268
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2276
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2269
2277
$filename . ' :' . $current -> line() .
2270
2278
" : '$which ' line " . $self -> lineNo($which ) .
2271
2279
" branch $branchId contains $nc elements but merge data contains $nd ."
2272
2280
);
2273
2281
}
2282
+ # LCOV_EXCL_STOP
2274
2283
for (my $i = ($nc > $nd ? $nd : $nc ) - 1; $i >= 0; --$i ) {
2275
2284
my $br = $d -> [$i ];
2276
2285
$c -> [$i ]-> merge($br );
@@ -2680,12 +2689,14 @@ sub _categorizeBranchCov
2680
2689
# a high probability event?
2681
2690
foreach my $line ($branchCurrent -> keylist()) {
2682
2691
my $type = $linemap -> type($filename , $linemap -> NEW, $line );
2692
+ # LCOV_EXCL_START
2683
2693
if ($type eq ' delete' ) {
2684
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2694
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2685
2695
" 'current' line $filename :$line should not be marked 'delete'" );
2686
2696
delete ($branchCurrent -> {$line });
2687
2697
next ;
2688
2698
}
2699
+ # LCOV_EXCL_STOP
2689
2700
my $data ;
2690
2701
if (!exists ($lineDataMap -> {$line })) {
2691
2702
# we expect the associated line to also have line coverage data
@@ -2735,9 +2746,10 @@ sub _categorizeBranchCov
2735
2746
my @baseBlocks = defined ($base ) ? $base -> blocks() : ();
2736
2747
2737
2748
if ($type eq ' insert' ) {
2738
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2749
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2739
2750
" baseline branch data should not be defined for inserted line $filename :$line "
2740
2751
) if defined ($base );
2752
+
2741
2753
foreach my $branchId (@currBlocks ) {
2742
2754
my $block = $categorized -> addBlock($branchId );
2743
2755
foreach my $br (@{$curr -> getBlock($branchId )}) {
@@ -2747,9 +2759,10 @@ sub _categorizeBranchCov
2747
2759
}
2748
2760
}
2749
2761
} elsif ($type eq ' delete' ) {
2750
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2762
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2751
2763
" current branch data should not be defined for deleted line $filename :$line "
2752
2764
) if defined ($curr );
2765
+
2753
2766
foreach my $branchId (@baseBlocks ) {
2754
2767
my $block = $categorized -> addBlock($branchId );
2755
2768
foreach my $br (@{$base -> getBlock($branchId )}) {
@@ -2759,7 +2772,7 @@ sub _categorizeBranchCov
2759
2772
}
2760
2773
}
2761
2774
} else {
2762
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2775
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2763
2776
" unexpected branch coverage type $type at $filename :$line " )
2764
2777
if $type ne ' equal' ;
2765
2778
@@ -2848,17 +2861,16 @@ sub _categorizeFunctionCov
2848
2861
my $line = $func -> line();
2849
2862
my $type = $linemap -> type($filename , $linemap -> NEW, $line );
2850
2863
$funcCovLines {$line } = 1;
2851
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2864
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2852
2865
" 'current' line $filename :$line should not be marked 'delete'" )
2853
2866
if $type eq ' delete' ;
2854
-
2855
2867
my $data ;
2856
2868
if (!exists ($lineDataMap -> {$line })) {
2857
2869
$data = LineData-> new($type );
2858
2870
$lineDataMap -> {$line } = $data ;
2859
2871
} else {
2860
2872
$data = $lineDataMap -> {$line };
2861
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2873
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2862
2874
" type mismatch " . $data -> type() .
2863
2875
" -> $type for $filename :$line " )
2864
2876
unless $data -> type() eq $type ;
@@ -2904,7 +2916,7 @@ sub _categorizeFunctionCov
2904
2916
if (!defined ($base )) {
2905
2917
# either this line was inserted or the line hasn't changed but
2906
2918
# 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 ,
2908
2920
" unexpected undef baseline function data for deleted $filename :$line "
2909
2921
) if $type eq ' delete' ;
2910
2922
my $hit = $curr -> hit();
@@ -2919,7 +2931,7 @@ sub _categorizeFunctionCov
2919
2931
$categorized -> addAliasDifferential($alias , [$hit , $tla ]);
2920
2932
}
2921
2933
} elsif (!defined ($curr )) {
2922
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2934
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2923
2935
" unexpected undef current function data for inserted $filename :$line "
2924
2936
) if $type eq ' insert' ;
2925
2937
my $hit = $base -> hit();
@@ -2934,7 +2946,7 @@ sub _categorizeFunctionCov
2934
2946
$categorized -> addAliasDifferential($alias , [$hit , $tla ]);
2935
2947
}
2936
2948
} else {
2937
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
2949
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
2938
2950
" unexpected function coverage type $type at $filename :$line " )
2939
2951
if $type ne ' equal' ;
2940
2952
# if we know end lines for this function, then check if there
@@ -3422,14 +3434,15 @@ sub _read_udiff
3422
3434
);
3423
3435
last ;
3424
3436
}
3437
+ # LCOV_EXCL_START
3425
3438
if (exists ($self -> [LINEMAP]-> {$key })) {
3426
- lcovutil::ignorable_error(
3427
- $lcovutil::ERROR_INCONSISTENT_DATA ,
3439
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
3428
3440
" $diff_file :$. : $key 'unchanged' entry found but diff records exist"
3429
3441
. ($file eq $key ? ' ' : " (substituted '$file ')" ));
3430
3442
# message ignored - delete the diff records
3431
3443
delete ($self -> [LINEMAP]-> {$key });
3432
3444
}
3445
+ # LCOV_EXCL_STOP
3433
3446
$self -> [UNCHANGED]-> {$key } = 1;
3434
3447
last ;
3435
3448
};
@@ -3467,16 +3480,18 @@ sub _read_udiff
3467
3480
$filename = $notNull ? $key : undef ;
3468
3481
3469
3482
if ($filename ) {
3483
+ # LCOV_EXCL_START
3470
3484
if (exists ($self -> [UNCHANGED]-> {$key })) {
3471
3485
lcovutil::ignorable_error(
3472
- $lcovutil::ERROR_INCONSISTENT_DATA ,
3486
+ $lcovutil::ERROR_INTERNAL ,
3473
3487
" $diff_file :$. : $filename marked unchanged but diff record found"
3474
3488
.
3475
3489
($file_new eq $key ? ' ' :
3476
3490
" (substituted '$file_new ')" ));
3477
3491
# OK - error ignored...remove the 'unchanged' marker
3478
3492
delete ($self -> [UNCHANGED]-> {$key });
3479
3493
}
3494
+ # LCOV_EXCL_STOP
3480
3495
$self -> [LINEMAP]-> {$key } = [];
3481
3496
}
3482
3497
if ($notNull ) {
@@ -4031,12 +4046,14 @@ sub _countBranchTlaData
4031
4046
my $diff = $differentialData -> getBlock($branchId );
4032
4047
foreach my $b (@$diff ) {
4033
4048
my $tla = $b -> [1];
4049
+ # LCOV_EXCL_START
4034
4050
unless (defined ($tla )) {
4035
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
4051
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
4036
4052
" undef TLA for branch $branchId of " . $self -> path() .
4037
4053
" :$line - lineTLA:$lineTla taken:" . $b -> [0]);
4038
4054
next ;
4039
4055
}
4056
+ # LCOV_EXCL_STOP
4040
4057
$fileSummary -> [SummaryInfo::BRANCH_DATA]-> [SummaryInfo::DATA ]
4041
4058
-> {$tla } += 1;
4042
4059
# keep track of all the branch TLAs found on this line...
@@ -4197,12 +4214,14 @@ sub _accountFunction
4197
4214
{
4198
4215
my ($fileSummary , $tla , $src_age ) = @_ ;
4199
4216
4217
+ # LCOV_EXCL_START
4200
4218
unless (defined ($tla )) {
4201
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
4219
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
4202
4220
" undef function TLA for age '$src_age ' of " .
4203
4221
$fileSummary -> name());
4204
4222
return 1; # error
4205
4223
}
4224
+ # LCOV_EXCL_STOP
4206
4225
4207
4226
$fileSummary -> [SummaryInfo::FUNCTION_DATA]-> [SummaryInfo::DATA ]-> {$tla } +=
4208
4227
1;
@@ -4230,8 +4249,9 @@ sub _countFunctionTlaData
4230
4249
defined ($lcovutil::cov_filter [$lcovutil::FILTER_FUNCTION_ALIAS ]);
4231
4250
my $h = $func -> hit();
4232
4251
my $mergedTla = $h -> [1];
4252
+ # LCOV_EXCL_START
4233
4253
if (!defined ($mergedTla )) {
4234
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
4254
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
4235
4255
" undef TLA for function '" . $func -> name() .
4236
4256
" ' hit " . $h -> [0] . " at line " .
4237
4257
$line . " (" . $lineData -> tla() .
@@ -4242,6 +4262,7 @@ sub _countFunctionTlaData
4242
4262
$h -> [1] = $mergedTla ;
4243
4263
# return;
4244
4264
}
4265
+ # LCOV_EXCL_STOP
4245
4266
4246
4267
if (!grep (/ ^$mergedTla $ / , (' DUB' , ' DCB' ))) {
4247
4268
# deleted lines don't have owner data...
@@ -4262,8 +4283,9 @@ sub _countFunctionTlaData
4262
4283
foreach my $alias (keys %$aliases ) {
4263
4284
my $data = $aliases -> {$alias };
4264
4285
my $tla = $data -> [1];
4286
+ # LCOV_EXCL_START
4265
4287
if (!defined ($tla )) {
4266
- lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA ,
4288
+ lcovutil::ignorable_error($lcovutil::ERROR_INTERNAL ,
4267
4289
" undef TLA for alias:'$alias ' hit:" .
4268
4290
$data -> [0] . " of function '" . $func -> name() .
4269
4291
" ' hit " . $h -> [0] . " at line " . $line . " (" .
@@ -4272,6 +4294,7 @@ sub _countFunctionTlaData
4272
4294
$tla = $data -> [0] == 0 ? ' UNC' : ' GNC' ;
4273
4295
$data -> [1] = $tla ;
4274
4296
}
4297
+ # LCOV_EXCL_STOP
4275
4298
_accountFunction($fileSummary , $tla , $src_age );
4276
4299
}
4277
4300
}
@@ -5529,9 +5552,13 @@ sub merge_child($$$)
5529
5552
my $name =
5530
5553
$childSummary -> type() eq ' top' ? " " : $childSummary -> name();
5531
5554
$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;
5535
5562
}
5536
5563
};
5537
5564
if ($@ ) {
@@ -6099,7 +6126,8 @@ if (0 == $exit_status && @SummaryInfo::coverageCriteriaScript) {
6099
6126
keys (%SummaryInfo::coverageCriteria ))
6100
6127
) {
6101
6128
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
6103
6131
6104
6132
my $msg = $criteria -> [0];
6105
6133
if ($criteria -> [0] ne ' top' ) {
0 commit comments