@@ -104,6 +104,7 @@ use lcovutil qw (set_tool_name define_errors parse_ignore_errors
104
104
$ERROR_DEPRECATED $ERROR_INCONSISTENT_DATA $ERROR_CALLBACK
105
105
$ERROR_RANGE $ERROR_PATH
106
106
$ERROR_PARALLEL $ERROR_CHILD report_parallel_error
107
+ report_exit_status
107
108
summarize_messages
108
109
$br_coverage $func_coverage
109
110
info $verbose init_verbose_flag debug $debug $devnull
@@ -272,6 +273,7 @@ sub gen_png($$$$$@);
272
273
package SummaryInfo ;
273
274
274
275
our @coverageCriteriaScript ;
276
+ our $criteriaCallback ;
275
277
our %coverageCriteria ; # hash of name->(type, success 0/1, string)
276
278
our $coverageCriteriaStatus = 0; # set to non-zero if we see any errors
277
279
our @criteriaCallbackTypes ; # include date, owner bin info
@@ -1059,7 +1061,7 @@ sub checkCoverageCriteria
1059
1061
my $self = shift ;
1060
1062
my $type = $self -> type();
1061
1063
return
1062
- unless (@coverageCriteriaScript &&
1064
+ unless ($criteriaCallback &&
1063
1065
(0 == scalar (@criteriaCallbackLevels ) ||
1064
1066
grep (/ $type / , @criteriaCallbackLevels )));
1065
1067
@@ -1136,29 +1138,18 @@ sub checkCoverageCriteria
1136
1138
' \' ' . $self -> type() . ' \' ' . $json . ' \' ' ;
1137
1139
# command: script name (top|dir|file) jsonString args..
1138
1140
lcovutil::info(1, " criteria: '$cmd '\n " );
1139
- if (open (HANDLE, " -|" , @coverageCriteriaScript ,
1140
- $self -> type() eq ' top' ? ' top' : $self -> name(),
1141
- $self -> type(), $json
1142
- )) {
1143
- my @msg ;
1144
- while (my $line = <HANDLE>) {
1145
- chomp $line ;
1146
- $line =~ s /\r // g ; # remove CR from line-end
1147
- next if ' ' eq $line ;
1148
- push (@msg , $line );
1149
- }
1150
- close (HANDLE);
1151
- my $status = $? >> 8;
1152
- my $name = $self -> type() eq ' top' ? " " : $self -> name();
1153
- $coverageCriteria {$name } = [$self -> type(), $status , \@msg ]
1154
- if (0 != $status ||
1155
- 0 != scalar (@msg ));
1156
- $coverageCriteriaStatus = $status
1157
- if $status != 0;
1158
- } else {
1159
- lcovutil::ignorable_error($lcovutil::ERROR_CALLBACK ,
1160
- " 'open(-| $cmd )' failed: \" $! \" " );
1161
- }
1141
+ my ($status , $msgs ) =
1142
+ $criteriaCallback -> check_criteria(
1143
+ $self -> type() eq ' top' ? ' top' : $self -> name(),
1144
+ $self -> type(), $json );
1145
+
1146
+ my $name = $self -> type() eq ' top' ? " " : $self -> name();
1147
+ $coverageCriteria {$name } = [$self -> type(), $status , $msgs ]
1148
+ if (0 != $status ||
1149
+ (defined $msgs &&
1150
+ 0 != scalar (@$msgs )));
1151
+ $coverageCriteriaStatus = $status
1152
+ if $status != 0;
1162
1153
my $end = Time::HiRes::gettimeofday();
1163
1154
$lcovutil::profileData {criteria }{
1164
1155
$self -> type() eq ' top' ? ' top' :
@@ -3567,6 +3558,7 @@ sub text
3567
3558
3568
3559
package SourceFile ;
3569
3560
our @annotateScript ;
3561
+ our $annotateCallback ;
3570
3562
our $annotateTooltip = ' Line %l: commit %C on %d by %F' ;
3571
3563
our $annotatedFiles = 0;
3572
3564
our $totalFiles = 0;
@@ -4310,7 +4302,7 @@ sub _load
4310
4302
# not exist - but that might be fine if it exists in the repo
4311
4303
my $repo_path = Cwd::realpath($path );
4312
4304
if (!defined ($repo_path )) {
4313
- if (0 == scalar ( @annotateScript ) &&
4305
+ if (! defined ( $annotateCallback ) &&
4314
4306
!$main::synthesizeMissingFile ) {
4315
4307
lcovutil::ignorable_error($lcovutil::ERROR_SOURCE ,
4316
4308
" \" " . $self -> path() . " \" does not exist: $! " .
@@ -4343,35 +4335,23 @@ sub _load
4343
4335
$lcovutil::profileData {check_version }{$self -> path()} = $end - $start ;
4344
4336
}
4345
4337
4346
- # stat($annotateScript);
4347
-
4348
- ANNOTATE: if (0 != scalar (@annotateScript )) {
4349
-
4350
- last ANNOTATE
4351
- if (scalar (@lcovutil::extractVersionScript ) ==
4352
- 0 && # already checked
4353
- lcovutil::fileExistenceBeforeCallbackError($repo_path ));
4354
-
4338
+ if (defined ($annotateCallback ) &&
4339
+ # also skip if we already emitted 'missing file' error
4340
+ (defined ($lcovutil::versionCallback ) ||
4341
+ !lcovutil::fileExistenceBeforeCallbackError($repo_path ))
4342
+ ) {
4355
4343
my $begin = Time::HiRes::gettimeofday();
4356
4344
my $lineNum = 0;
4357
- my $cmd = join (' ' , @annotateScript ) . ' \' ' . $repo_path . ' \' ' ;
4358
- lcovutil::info(1, " annotate: '$cmd '\n " );
4359
- my $found ; # check that either all lines are annotated or none are
4360
- local *HANDLE;
4361
- if (open (HANDLE, " -|" , @annotateScript , $repo_path )) {
4362
- while (my $line = <HANDLE>) {
4363
- chomp $line ;
4364
- $line =~ s /\r // g ; # remove CR from line-end
4345
+
4346
+ my ($status , $lines ) = $annotateCallback -> annotate($repo_path );
4347
+ if (!$status && defined ($lines )) {
4348
+ my $found ; # check that either all lines are annotated or none are
4349
+ foreach my $line (@$lines ) {
4350
+
4351
+ my ($text , $abbrev , $full , $when , $commit ) = @$line ;
4365
4352
++$lineNum ;
4366
4353
4367
- my ($commit , $owner , $when , $text ) = split (/ \| / , $line , 4);
4368
4354
my $age = _computeAge($when , $path );
4369
- # semicolon is not a legal character in email address -
4370
- # so we use that to delimit the 'abbreviated name' and
4371
- # the 'full name' - in case they are different.
4372
- # this is an attempt to be backward-compatible with
4373
- # existing annotation scripts which return only one name
4374
- my ($abbrev , $full ) = split (/ ;/ , $owner , 2);
4375
4355
if ($commit ne ' NONE' ) {
4376
4356
die (" inconsistent 'annotate' data for '$repo_path ': both 'commit' and 'no commit' lines"
4377
4357
) if (defined ($found ) && !$found );
@@ -4396,38 +4376,27 @@ sub _load
4396
4376
SourceLine-> new($lineNum , $text , $abbrev , $full ,
4397
4377
$when , $age , $commit );
4398
4378
}
4399
- close (HANDLE);
4400
- my $status = $? >> 8;
4401
4379
4402
4380
my $end = Time::HiRes::gettimeofday();
4403
4381
4404
4382
$lcovutil::profileData {annotate }{$self -> path()} = $end - $begin ;
4405
- if (0 == $status ) {
4406
- ++$annotatedFiles if $found ;
4407
- $self -> _synthesize($countdata , 1); # fake annotations too
4408
- return $self ;
4409
- }
4383
+
4384
+ ++$annotatedFiles if $found ;
4385
+ $self -> _synthesize($countdata , 1); # fake annotations too
4386
+ return $self ;
4387
+ } else {
4410
4388
4411
4389
# non-zero exit status: something bad happened in annotation
4412
4390
# if we ignore the error - then fall through and just try to load the file
4413
- my $text = ' : ' . $self -> [LINES]-> [0]-> text() . ' ...'
4414
- if @{$self -> [LINES]};
4391
+ my $text = ' ' ;
4392
+ $text = ' : ' . $lines -> [0]-> [0] . ' ...'
4393
+ if $lines && @$lines ;
4415
4394
# might be useful to provide more than one line of context - if there is more than one line?
4416
- lcovutil::ignorable_error(
4417
- $lcovutil::ERROR_ANNOTATE_SCRIPT ,
4418
- ($! ? " annotate command '$cmd ' pipe error: $! " :
4419
- " non-zero exit status from annotate '$cmd ' pipe"
4420
- ) .
4421
- ($text ? $text : ' ' ));
4422
- # if falling through, clear the LINES array that might have been
4423
- # populated in the annotate loop. Needs to be empty for bare load
4424
- # or synthesize operation
4425
- $self -> [LINES] = [];
4426
- } else {
4427
- # open failed.
4428
- lcovutil::ignorable_error($lcovutil::ERROR_ANNOTATE_SCRIPT ,
4429
- " 'open(-| $cmd )' failed: \" $! \"\n " );
4430
- }
4395
+
4396
+ lcovutil::report_exit_status($lcovutil::ERROR_ANNOTATE_SCRIPT ,
4397
+ " annotate command failed" ,
4398
+ $status , ' ' , $text );
4399
+ } # end if error
4431
4400
} # end if annotate script exists
4432
4401
4433
4402
# Check if file exists and is readable
@@ -4862,15 +4831,11 @@ sub compute
4862
4831
if ($consumption > $lcovutil::maxMemory );
4863
4832
my $child = wait ();
4864
4833
my $childstatus = $? ;
4865
- --$currentParallel ;
4866
- if (!exists ($children -> {$child })) {
4867
- # this should not happen..
4868
- lcovutil::ignorable_error($lcovutil::ERROR_PARALLEL ,
4869
- " lost track of children: currentSize:$currentSize wait:$child , currentParallel:$currentParallel children:("
4870
- . join (' , ' , keys (%$children ))
4871
- . " )" );
4834
+ unless (exists ($children -> {$child })) {
4835
+ lcovutil::report_unknown_child($child );
4872
4836
next WORK;
4873
4837
}
4838
+ --$currentParallel ;
4874
4839
my ($summary , $fullname , $parentData , $now ) =
4875
4840
@{$children -> {$child }};
4876
4841
my ($parentSummary , $parentPerTestData , $parentPath ) =
@@ -5076,16 +5041,11 @@ sub compute
5076
5041
while ($currentParallel != 0) {
5077
5042
my $child = wait ();
5078
5043
my $childstatus = $? ;
5079
- --$currentParallel ;
5080
- if (!exists ($children -> {$child })) {
5081
- # this should not happen..
5082
- lcovutil::ignorable_erro($lcovutil::ERROR_PARALLEL ,
5083
- " lost track of children in tail: wait:$child , currentParallel:$currentParallel children:("
5084
- . join (' , ' , keys (%$children ))
5085
- . " )" );
5044
+ unless (exists ($children -> {$child })) {
5045
+ lcovutil::report_unknown_child($child );
5086
5046
next ;
5087
5047
}
5088
-
5048
+ -- $currentParallel ;
5089
5049
my ($summary , $fullname , $parentSummary , $parentPath , $now ) =
5090
5050
@{$children -> {$child }};
5091
5051
$self -> merge_child($child , $childstatus );
@@ -5210,7 +5170,7 @@ package main;
5210
5170
5211
5171
# Global variables & initialization
5212
5172
5213
- lcovutil::save_cmd_line(\@ARGV , $FindBin::RealBin );
5173
+ lcovutil::save_cmd_line(\@ARGV , " $FindBin::RealBin " );
5214
5174
5215
5175
# TraceFile Instance containing all data from the 'current' .info file
5216
5176
# - constructed at start of GenHtml
@@ -5436,6 +5396,16 @@ foreach my $rc ([\@datebins, \@rc_date_bins],
5436
5396
@{$rc -> [0]} = @{$rc -> [1]} unless (@{$rc -> [0]});
5437
5397
}
5438
5398
5399
+ foreach my $cb ([\$SourceFile::annotateCallback , \@SourceFile::annotateScript ],
5400
+ [\$SummaryInfo::criteriaCallback ,
5401
+ \@SummaryInfo::coverageCriteriaScript
5402
+ ]
5403
+ ) {
5404
+
5405
+ ${$cb -> [0]} = lcovutil::configure_callback(@{$cb -> [1]})
5406
+ if scalar (@{$cb -> [1]});
5407
+ }
5408
+
5439
5409
foreach my $data ([' criteria_callback_levels' , \@criteriaCallbackLevels ,
5440
5410
[' top' , ' directory' , ' file' ]
5441
5411
],
@@ -5748,7 +5718,9 @@ if (0 == $exit_status &&
5748
5718
print (STDERR $msg );
5749
5719
}
5750
5720
}
5751
- $exit_status = $SummaryInfo::coverageCriteriaStatus ;
5721
+ # fail for signal or status
5722
+ $exit_status = (($SummaryInfo::coverageCriteriaStatus & 0xFF) |
5723
+ ($SummaryInfo::coverageCriteriaStatus >> 8));
5752
5724
}
5753
5725
5754
5726
lcovutil::save_profile(File::Spec-> catfile($output_directory , ' genhtml' ));
0 commit comments