@@ -258,12 +258,12 @@ sub write_html(*$);
258
258
sub write_html_prolog (*$$);
259
259
sub write_html_epilog (*$;$);
260
260
261
- sub write_header (*$$$$$);
261
+ sub write_header (*$$$$$$ );
262
262
sub write_header_prolog (*$);
263
263
sub write_header_line (*@);
264
264
sub write_header_epilog (*$);
265
265
266
- sub write_file_table (*$$$$$);
266
+ sub write_file_table (*$$$$$$ );
267
267
sub write_file_table_prolog (*$$$@);
268
268
sub write_file_table_entry (*$$@);
269
269
sub write_file_table_detail_entry (*$$$$@);
@@ -359,6 +359,9 @@ our @cutpoints;
359
359
our @ageGroupHeader ;
360
360
our %ageHeaderToBin ;
361
361
362
+ our @truncateOwnerTableLevels ; # default: truncate everywhere if enabled
363
+ our $ownerTableElements ; # default: do not truncate
364
+
362
365
use constant {
363
366
TYPE => 0,
364
367
NAME => 1,
@@ -824,7 +827,7 @@ sub findOwnerList
824
827
# branchCovData = [missed, total] or undef if not enabled
825
828
# functionCov = [missed, total] or undef if not enabled
826
829
# - sorted in descending order number of missed lines
827
- my ($self , $all ) = @_ ;
830
+ my ($self , $callback_type , $truncate_me , $ all ) = @_ ;
828
831
829
832
my @owners ;
830
833
foreach my $owner (keys (%{$self -> [LINE_DATA]-> [OWNERS]})) {
@@ -867,7 +870,22 @@ sub findOwnerList
867
870
$b -> [1]-> [1] <=> $a -> [1]-> [1] || # then total
868
871
$a -> [0] cmp $b -> [0]
869
872
} @owners ); # then by name
870
- return scalar (@owners ) ? \@owners : undef ;
873
+ my $truncated ;
874
+ if ($truncate_me &&
875
+ defined ($ownerTableElements ) &&
876
+ $ownerTableElements < scalar (@owners ) &&
877
+ (0 == scalar (@truncateOwnerTableLevels ) ||
878
+ grep (/ $callback_type / , @truncateOwnerTableLevels ))
879
+ ) {
880
+ # don't truncate the 'primary' key owner table
881
+
882
+ $truncated = (scalar (@owners ) - $ownerTableElements );
883
+ # lcovutil::info("truncating $truncated elements in header table\n");
884
+ splice (@owners , $ownerTableElements );
885
+ } else {
886
+ $truncated = 0;
887
+ }
888
+ return (scalar (@owners ) ? \@owners : undef , $truncated );
871
889
}
872
890
873
891
sub append
@@ -1481,12 +1499,12 @@ sub summary
1481
1499
1482
1500
sub findOwnerList
1483
1501
{
1484
- my ( $self , $all ) = @_ ;
1502
+ my $self = shift ;
1485
1503
# return [ [owner, lineCovData, branchCovData]] for each owner
1486
1504
# where lineCovData = [missedCount, totalCount, callback]
1487
1505
# branchCovData = [missed, total, callback] or undef if not enabled
1488
1506
# - sorted in descending order number of missed lines
1489
- return $self -> summary()-> findOwnerList($all );
1507
+ return $self -> summary()-> findOwnerList(@_ );
1490
1508
}
1491
1509
1492
1510
sub dateDetailCallback
@@ -6288,6 +6306,8 @@ my %genhtml_rc_opts = (
6288
6306
" select_script" => \@rc_select_script ,
6289
6307
' num_context_lines' => \$InInterestingRegion::num_context_lines ,
6290
6308
' genhtml_date_bins' => \@rc_date_bins ,
6309
+ ' truncate_owner_table' => \@truncateOwnerTableLevels ,
6310
+ ' owner_table_entries' => \$ownerTableElements ,
6291
6311
' genhtml_synthesize_missing' => \$synthesizeMissingFile ,
6292
6312
' scope_regexp' => \$verboseScopeRegexp ,);
6293
6313
@@ -6424,6 +6444,24 @@ if (@SourceFile::annotateScript) {
6424
6444
@datebins = sort (keys %uniqify );
6425
6445
}
6426
6446
SummaryInfo::setAgeGroups(@datebins );
6447
+
6448
+ if (defined ($show_ownerBins )) {
6449
+ @truncateOwnerTableLevels =
6450
+ split ($lcovutil::split_char ,
6451
+ join ($lcovutil::split_char , @truncateOwnerTableLevels ));
6452
+ foreach my $l (@truncateOwnerTableLevels ) {
6453
+ lcovutil::ignorable_error($lcovutil::ERROR_USAGE ,
6454
+ " Unknown 'truncate_owner_table' level '$l ': should be 'top', 'directory', or 'file'."
6455
+ ) unless grep (/ ^$l $ / , (' top' , ' directory' , ' file' ));
6456
+ }
6457
+
6458
+ lcovutil::ignorable_error($lcovutil::ERROR_USAGE ,
6459
+ " Unsupported value 'owner_table_entries = $ownerTableElements ': expected positive integer."
6460
+ )
6461
+ unless (!defined ($ownerTableElements ) ||
6462
+ (Scalar::Util::looks_like_number($ownerTableElements ) &&
6463
+ 0 < $ownerTableElements ));
6464
+ }
6427
6465
} else {
6428
6466
$treatNewFileAsBaseline = undef ;
6429
6467
die (" \" --show-owners\" option requires \" --annotate-script\" for revision control integration"
@@ -7028,9 +7066,9 @@ sub html_create($$)
7028
7066
# sub write_dir_page($$$$$$$;$)
7029
7067
sub write_dir_page
7030
7068
{
7031
- my ($ctrls , $page_suffix , $title , $rel_dir , $base_dir , $trunc_dir ,
7032
- $summary , $perTestcaseResult )
7033
- = @_ ;
7069
+ my ($callback_type , $ctrls , $page_suffix ,
7070
+ $title , $rel_dir , $base_dir ,
7071
+ $trunc_dir , $summary , $perTestcaseResult ) = @_ ;
7034
7072
7035
7073
my $bin_prefix = $ctrls -> [3];
7036
7074
# Generate directory overview page including details
@@ -7044,10 +7082,11 @@ sub write_dir_page
7044
7082
$title .= " - " if ($trunc_dir ne " " );
7045
7083
write_html_prolog(*HTML_HANDLE, $base_dir , " LCOV - $title$trunc_dir " );
7046
7084
my $activeTlaColsForType =
7047
- write_header(*HTML_HANDLE, $ctrls , $trunc_dir , $rel_dir , $summary ,
7048
- undef );
7085
+ write_header(*HTML_HANDLE, $callback_type , $ctrls , $trunc_dir ,
7086
+ $rel_dir , $summary , undef );
7049
7087
if (0 != $summary -> sources()) {
7050
- write_file_table(*HTML_HANDLE, $base_dir , $perTestcaseResult ,
7088
+ write_file_table(*HTML_HANDLE, $callback_type , $base_dir ,
7089
+ $perTestcaseResult ,
7051
7090
$summary , $ctrls , $activeTlaColsForType );
7052
7091
} else {
7053
7092
my $msg =
@@ -7069,6 +7108,7 @@ sub write_summary_pages($$$$$$$$)
7069
7108
my ($name , $summaryType , $summary , $show_details ,
7070
7109
$rel_dir , $base_dir , $trunc_dir , $testhashes ) = @_ ;
7071
7110
7111
+ my $callback_type = $summaryType == 1 ? ' directory' : ' top' ;
7072
7112
foreach my $c ($summary -> sources()) {
7073
7113
my $child = $summary -> get_source($c );
7074
7114
# filter this one out if no data
@@ -7143,7 +7183,7 @@ sub write_summary_pages($$$$$$$$)
7143
7183
}
7144
7184
7145
7185
foreach my $params (@dirPageCalls ) {
7146
- write_dir_page(@$params );
7186
+ write_dir_page($callback_type , @$params );
7147
7187
last # only write 'index.html' - not the sorted versions
7148
7188
if ($summary -> is_empty());
7149
7189
}
@@ -7182,6 +7222,7 @@ sub write_function_page($$$$$$$$$$$$$)
7182
7222
File::Spec-> catfile($trunc_dir , $base_name ) . " - functions" ;
7183
7223
write_html_prolog(*HTML_HANDLE, $base_dir , $pagetitle );
7184
7224
write_header(*HTML_HANDLE,
7225
+ ' file' , # function table always written from 'file' level
7185
7226
[4, ' name' , $sort_type ,],
7186
7227
File::Spec-> catfile($trunc_dir , $base_name ),
7187
7228
File::Spec-> catfile($rel_dir , $base_name ),
@@ -7317,6 +7358,7 @@ sub process_file($$$$$)
7317
7358
File::Spec-> catfile($trunc_dir , $base_name );
7318
7359
write_html_prolog(*HTML_HANDLE, $base_dir , $pagetitle );
7319
7360
write_header(*HTML_HANDLE,
7361
+ ' file' ,
7320
7362
[2, ' name' , 0],
7321
7363
File::Spec-> catfile($trunc_dir , $base_name ),
7322
7364
File::Spec-> catfile($rel_dir , $base_name ),
@@ -7707,7 +7749,7 @@ sub write_description_file($$)
7707
7749
html_create(*HTML_HANDLE, " descriptions.$html_ext " );
7708
7750
7709
7751
write_html_prolog(*HTML_HANDLE, " " , " LCOV - test case descriptions" );
7710
- write_header(*HTML_HANDLE, [3, ' name' , 0], " " , " " , $summary , undef );
7752
+ write_header(*HTML_HANDLE, ' top ' , [3, ' name' , 0], " " , " " , $summary , undef );
7711
7753
7712
7754
write_test_table_prolog(*HTML_HANDLE,
7713
7755
" Test case descriptions - alphabetical list" );
@@ -10518,14 +10560,19 @@ sub buildDateSummaryTable($$$$$$$$$)
10518
10560
return \@table ;
10519
10561
}
10520
10562
10521
- sub buildOwnerSummaryTable ($$$$$$$$$)
10563
+ sub buildOwnerSummaryTable ($$$$$$$$$$ )
10522
10564
{
10523
- my ($ownerList , $summary , $covType ,
10524
- $fileDetail , $nextLocationCallback , $title ,
10525
- $detailLink , $numRows , $activeTlaList ) = @_ ;
10565
+ my ($ownerList , $num_truncated , $summary ,
10566
+ $covType , $fileDetail , $nextLocationCallback ,
10567
+ $title , $detailLink , $numRows ,
10568
+ $activeTlaList ) = @_ ;
10526
10569
10527
10570
$title .= " (containing " .
10528
10571
($main::show_ownerBins ? " " : " un-exercised " ) . " code)" ;
10572
+ $title .=
10573
+ " : $num_truncated author" .
10574
+ ($num_truncated == 1 ? ' ' : ' s' ) . ' truncated'
10575
+ if $num_truncated ;
10529
10576
10530
10577
$title =
10531
10578
" <a href=\" $detailLink \" title=\" Click to include ownership details in file table\" >$title </a>"
@@ -10731,10 +10778,12 @@ sub build_html_path($$$$$)
10731
10778
# list of all TLA types if user has asked not to suppress all-zero
10732
10779
# columns)
10733
10780
10734
- sub write_header (*$$$$$)
10781
+ sub write_header (*$$$$$$ )
10735
10782
{
10736
10783
local *HTML_HANDLE = shift ;
10737
- my ($ctrl , $trunc_name , $rel_filename , $summary , $fileDetail ) = @_ ;
10784
+ my ($callback_type , $ctrl , $trunc_name , $rel_filename , $summary ,
10785
+ $fileDetail )
10786
+ = @_ ;
10738
10787
my ($type , $primary_key , $sort_type , $bin_type ) = @$ctrl ;
10739
10788
my $base_dir ;
10740
10789
my $view ;
@@ -11174,14 +11223,18 @@ END_OF_HTML
11174
11223
# first, make sure there is owner data here (ie., owner data
11175
11224
# was collected, or both that there is owner data and some
11176
11225
# owners have uncovered code)
11177
- my $ownerList = $summary -> findOwnerList($main::show_ownerBins &&
11178
- $main::show_ownerBins eq ' all' );
11226
+ # This it the header table - so we want to truncate the owner
11227
+ # list if it is too long (and the user asked us to)
11228
+ my ($ownerList , $truncated ) =
11229
+ $summary -> findOwnerList($callback_type , 1,
11230
+ $main::show_ownerBins && $main::show_ownerBins eq ' all' );
11179
11231
if (defined ($ownerList )) {
11180
11232
my $ownerBinDetailPage = " index-owner.$html_ext "
11181
11233
if $type != $HDR_SOURCE ;
11182
11234
11183
11235
my $table =
11184
11236
buildOwnerSummaryTable($ownerList ,
11237
+ $truncated ,
11185
11238
$summary ,
11186
11239
SummaryInfo::LINE_DATA,
11187
11240
$fileDetail ,
@@ -11196,6 +11249,7 @@ END_OF_HTML
11196
11249
if ($lcovutil::br_coverage ) {
11197
11250
my $br_table =
11198
11251
buildOwnerSummaryTable($ownerList ,
11252
+ $truncated ,
11199
11253
$summary ,
11200
11254
SummaryInfo::BRANCH_DATA,
11201
11255
$fileDetail ,
@@ -11348,7 +11402,7 @@ sub get_br_code($$$$$$)
11348
11402
}
11349
11403
11350
11404
#
11351
- # write_file_table(filehandle, base_dir, perTestcaseData,
11405
+ # write_file_table(filehandle, callback_type, base_dir, perTestcaseData,
11352
11406
# parentSummary, ctrlSettings, activeTlaCols)
11353
11407
# ctrlSettings = [fileview, sort_type, details_type, sort_name]
11354
11408
# perTestcaseData = [testhash, testfnchash, testbrhash]
@@ -11370,14 +11424,15 @@ sub get_br_code($$$$$$)
11370
11424
# otherwise.
11371
11425
#
11372
11426
11373
- sub write_file_table (*$$$$$)
11427
+ sub write_file_table (*$$$$$$ )
11374
11428
{
11375
11429
local *HTML_HANDLE = $_ [0];
11376
- my $base_dir = $_ [1];
11377
- my $perTestcaseData = $_ [2]; # undef or [lineCov, funcCov, branchCov]
11378
- my $dirSummary = $_ [3]; # SummaryInfo object
11379
- my ($fileview , $primary_key , $sort_type , $bin_type ) = @{$_ [4]};
11380
- my $activeTlaCols = $_ [5];
11430
+ my $callback_type = $_ [1];
11431
+ my $base_dir = $_ [2];
11432
+ my $perTestcaseData = $_ [3]; # undef or [lineCov, funcCov, branchCov]
11433
+ my $dirSummary = $_ [4]; # SummaryInfo object
11434
+ my ($fileview , $primary_key , $sort_type , $bin_type ) = @{$_ [5]};
11435
+ my $activeTlaCols = $_ [6];
11381
11436
# $fileview == 0 if listing directories, 1 if listing files
11382
11437
# $primary_key in ("name", "owner", "date"). If $primary_key is:
11383
11438
# - 'name': leftmost column is file/directory name -
@@ -11570,6 +11625,17 @@ sub write_file_table(*$$$$$)
11570
11625
} else {
11571
11626
@sorted = sort (keys (%owners ));
11572
11627
}
11628
+ # don't truncate the 'owner detail table'
11629
+ # if user asked to see the page, then they want to be able to navigate
11630
+ # to all users
11631
+ # if (defined($ownderTableElements) &&
11632
+ # $ownerTableElements < scalar(@sorted)) &&
11633
+ # (0 == scalar(@truncateOwnerTableLevels) ||
11634
+ # grep(/$callback_type/, @truncateOwnerTableLevels)))) {
11635
+ # # truncate owner list in header table
11636
+ # splice(@sorted, $ownerTableElements);
11637
+ # }
11638
+
11573
11639
foreach my $owner (@sorted ) {
11574
11640
push (@tableRows ,
11575
11641
FileOrDirectoryOwnerCallback-> new($owner , $dirSummary ));
@@ -11623,7 +11689,12 @@ sub write_file_table(*$$$$$)
11623
11689
# do I need an option to suppress the list of owners?
11624
11690
# maybe too much information, in some circumstances?
11625
11691
# are there any non-empty owner tables here?
11626
- my $ownerList = $primaryCb -> findOwnerList($all );
11692
+ # If user explicitly asks to see the 'owner detail' page,
11693
+ # then they must be interested in which code is written by
11694
+ # each author - so we should not truncate the list
11695
+ my ($ownerList , $runcated ) =
11696
+ $primaryCb -> findOwnerList($callback_type , 0, $all );
11697
+ die (" unexpected truncate count" ) unless $runcated == 0;
11627
11698
push (@secondaryRows , @$ownerList )
11628
11699
if defined ($ownerList );
11629
11700
}
0 commit comments