@@ -4948,11 +4948,15 @@ sub new
4948
4948
my $worklist = $self -> [$WORKLIST_IDX ];
4949
4949
my $top_level_summary = $self -> [0];
4950
4950
# no parent data for top-level
4951
+ my $toplevelPerTestData =
4952
+ ($main::hierarchical || $main::flat ) ? [{}, {}, {}] : undef ;
4951
4953
$pending -> {" " } = [
4952
4954
[' top' ,
4953
- [$top_level_summary , undef , $top_level_summary -> name()]
4954
- , # summary, per-test data, name
4955
- [' root' ], [' root' ],
4955
+ [$top_level_summary , $toplevelPerTestData ,
4956
+ $top_level_summary -> name()
4957
+ ],
4958
+ [' root' ],
4959
+ [' root' ],
4956
4960
[undef , undef ]
4957
4961
],
4958
4962
{}
@@ -5146,17 +5150,16 @@ sub merge_one
5146
5150
5147
5151
sub compute_one
5148
5152
{
5149
- my ($type , $name , $summary , $parentSummary , $rel_dir , $base_dir , $trunc_dir )
5153
+ my ($type , $name , $summary , $parentSummary , $perTestData ,
5154
+ $rel_dir , $base_dir , $trunc_dir )
5150
5155
= @_ ;
5151
5156
5152
- my $perTestData ;
5153
5157
if (' file' eq $type ) {
5154
5158
my ($testdata , $testfncdata , $testbrdata ) =
5155
5159
main::process_file($summary , $parentSummary ,
5156
5160
$trunc_dir , $rel_dir , $name );
5157
5161
$perTestData = [$testdata , $testfncdata , $testbrdata ];
5158
5162
} elsif (' dir' eq $type ) {
5159
- $perTestData = [{}, {}, {}];
5160
5163
# process the directory...
5161
5164
main::write_summary_pages($name , 1, # this is a directory,
5162
5165
$summary , $main::show_details ,
@@ -5166,11 +5169,12 @@ sub compute_one
5166
5169
die (" unexpected task" )
5167
5170
unless ' top' eq $type ;
5168
5171
# Create sorted pages
5169
- main::write_summary_pages(
5170
- $name , 0, # 0 == list directories
5171
- $summary ,
5172
- 0, # don't generate 'details' links for top-level report
5173
- " ." , " " , undef , undef );
5172
+ main::write_summary_pages($name , 0, # 0 == list directories
5173
+ $summary ,
5174
+ # generate top-level 'details' in flat or hierarchical modes
5175
+ $main::show_details &&
5176
+ ($main::flat || $main::hierarchical ),
5177
+ " ." , " " , undef , $perTestData );
5174
5178
}
5175
5179
$summary -> checkCoverageCriteria();
5176
5180
return $perTestData ;
@@ -5295,9 +5299,10 @@ sub compute
5295
5299
5296
5300
eval {
5297
5301
$thisTestData =
5298
- compute_one($type , $name , $selfSummary ,
5299
- $parentSummary , $rel_dir , $base_dir ,
5300
- $trunc_dir );
5302
+ compute_one($type , $name ,
5303
+ $selfSummary , $parentSummary ,
5304
+ $perTestData , $rel_dir ,
5305
+ $base_dir , $trunc_dir );
5301
5306
5302
5307
# clear the parent pointer that we hacked into place. Don't want that
5303
5308
# extra data returned by dumper.
@@ -5332,7 +5337,8 @@ sub compute
5332
5337
$lcovutil::profileData {child }{$name } = $childEnd - $childStart ;
5333
5338
eval {
5334
5339
Storable::store(
5335
- [$perTestData ,
5340
+ [$thisTestData ,
5341
+ $parentPerTestData ,
5336
5342
$selfSummary ,
5337
5343
$criteria ,
5338
5344
[$SourceFile::annotatedFiles - $annotateCount ,
@@ -5356,9 +5362,9 @@ sub compute
5356
5362
5357
5363
my $thisTestData =
5358
5364
compute_one($type , $name , $selfSummary , $parentSummary ,
5359
- $rel_dir , $base_dir , $trunc_dir );
5365
+ $perTestData , $ rel_dir , $base_dir , $trunc_dir );
5360
5366
5361
- $self -> merge_one($perTestData , $name , $thisTestData ,
5367
+ $self -> merge_one($parentPerTestData , $name , $thisTestData ,
5362
5368
$selfSummary , $parentSummary , $parentPath );
5363
5369
my $end = Time::HiRes::gettimeofday();
5364
5370
$lcovutil::profileData {$type }{$name } = $end - $start ;
@@ -5433,7 +5439,9 @@ sub merge_child($$$)
5433
5439
if -f $dumpfile ;
5434
5440
if (defined ($data )) {
5435
5441
eval {
5436
- my ($perTest , $summary , $criteria , $countData , $update ) = @$data ;
5442
+ my ($perTest , $pPerTestData , $summary , $criteria , $countData ,
5443
+ $update )
5444
+ = @$data ;
5437
5445
die (" unexpected restored count data" )
5438
5446
if (($type eq ' file' && $countData -> [1] != 1) ||
5439
5447
($type ne ' file' &&
@@ -6881,19 +6889,21 @@ sub get_relative_base_path($)
6881
6889
6882
6890
sub read_testfile ($)
6883
6891
{
6892
+ my $file = shift ;
6884
6893
my %result ;
6885
6894
my $test_name ;
6886
6895
my $changed_testname ;
6887
6896
local *TEST_HANDLE;
6888
6897
6889
- open (TEST_HANDLE, " <" , $_ [0] ) or
6890
- die (" cannot open $_ [0 ]: $! \n " );
6898
+ open (TEST_HANDLE, " <" , $file ) or
6899
+ die (" cannot open $file ]: $! \n " );
6891
6900
6892
6901
while (<TEST_HANDLE>) {
6893
6902
chomp ($_ );
6894
6903
s /\r // g ;
6895
6904
# Match lines beginning with TN:<whitespace(s)>
6896
- if (/ ^TN:\s +(.*?)\s *$ / ) {
6905
+ next if / ^#/ ; # skip comment
6906
+ if (/ ^TN:\s *(.*?)\s *$ / ) {
6897
6907
# Store name for later use
6898
6908
$test_name = $1 ;
6899
6909
if ($test_name =~ s /\W / _/ g ) {
@@ -6902,10 +6912,12 @@ sub read_testfile($)
6902
6912
}
6903
6913
6904
6914
# Match lines beginning with TD:<whitespace(s)>
6905
- if (/ ^TD:\s + (.*?)\s *$ / ) {
6915
+ if (/ ^TD:\s * (.*?)\s *$ / ) {
6906
6916
if (!defined ($test_name )) {
6907
- die (" Found test description without prior test name in $_ [0]:$. \n "
6917
+ lcovutil::ignorable_error($lcovutil::ERROR_FORMAT ,
6918
+ " \" $file \" :$. : Found test description without prior test name."
6908
6919
);
6920
+ next ;
6909
6921
}
6910
6922
# Check for empty line
6911
6923
if ($1 ) {
@@ -6919,10 +6931,15 @@ sub read_testfile($)
6919
6931
}
6920
6932
6921
6933
close (TEST_HANDLE) or die (" unable to close HTML file: $! \n " );
6934
+ if (!%result ) {
6935
+ lcovutil::ignorable_error($lcovutil::ERROR_EMPTY ,
6936
+ " no test descriptions found in '$file '." );
6937
+ }
6922
6938
6923
6939
if ($changed_testname ) {
6924
6940
lcovutil::ignorable_error($lcovutil::ERROR_FORMAT ,
6925
- " invalid characters removed from testname in descriptions file $_ [0]" );
6941
+ " invalid characters removed from testname in descriptions file '$file '."
6942
+ );
6926
6943
}
6927
6944
6928
6945
return \%result ;
@@ -8675,24 +8692,17 @@ END_OF_HTML
8675
8692
write_html($handle , " <td class=\" testPer\" ></td>\n " );
8676
8693
}
8677
8694
write_html($handle , " <td class=\" testPer\" >$rate </td>\n " );
8678
- if ($covtype != SummaryInfo::FUNCTION_DATA) {
8695
+ write_html($handle , " <td class='testNum'>$found </td>\n " );
8696
+ if ($main::show_hitTotalCol ) {
8679
8697
write_html($handle ,
8680
- " <td class='testNum'>$found </td>\n " );
8681
- if ($main::show_hitTotalCol ) {
8682
- write_html($handle ,
8683
- " <td class='testNum'>$hit </td>\n " );
8684
- }
8685
- if ($main::show_tla ) {
8686
- foreach my $tla (@{$activeTlaCols -> {$covtype }}) {
8687
- my $count = $callback -> count($tla );
8688
- $count = " " if 0 == $count ;
8689
- write_html($handle ,
8690
- " <td class=coverNumDflt>$count </td>\n " );
8691
- }
8698
+ " <td class='testNum'>$hit </td>\n " );
8699
+ }
8700
+ if ($main::show_tla ) {
8701
+ foreach my $tla (@{$activeTlaCols -> {$covtype }}) {
8702
+ my $count = $callback -> count($tla );
8703
+ $count = " " if 0 == $count ;
8704
+ write_html($handle , " <td class=coverNumDflt>$count </td>\n " );
8692
8705
}
8693
- } else {
8694
- write_html($handle ,
8695
- " <td class=\" testNum\" >$found / $hit </td>\n " );
8696
8706
}
8697
8707
}
8698
8708
write_html($handle , " </tr>\n " );
@@ -10685,7 +10695,11 @@ sub write_file_table(*$$$$$)
10685
10695
# Determine HTML code for column headings
10686
10696
my $hide = $HEAD_NO_DETAIL ;
10687
10697
my $show = $HEAD_NO_DETAIL ;
10688
- if ($dirSummary -> type() eq ' directory' && $show_details ) {
10698
+ if (($dirSummary -> type() eq ' directory' ||
10699
+ $main::flat ||
10700
+ $main::hierarchical ) &&
10701
+ $show_details
10702
+ ) {
10689
10703
# "detailed" if line coverage hash not empty
10690
10704
my $detailed =
10691
10705
defined ($perTestcaseData ) && scalar (%{$perTestcaseData -> [0]});
0 commit comments