Skip to content

Commit 87d01f3

Browse files
committed
Use better title if there are multiple input files
Signed-off-by: Henry Cox <[email protected]>
1 parent 944cb8b commit 87d01f3

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

bin/genhtml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ sub print_usage(*);
227227
sub gen_html();
228228
sub html_create($$);
229229
sub process_file($$$$$);
230+
sub compute_title($$);
230231
sub get_prefix($@);
231232
sub shorten_prefix($);
232233
sub get_relative_base_path($);
@@ -6473,23 +6474,15 @@ if (!@info_filenames) {
64736474
}
64746475

64756476
# Generate a title if none is specified
6476-
if (!$test_title) {
6477-
if (scalar(@info_filenames) == 1) {
6478-
# Only one filename specified, use it as title
6479-
$test_title = basename($info_filenames[0]);
6480-
} else {
6481-
# More than one filename specified, used default title
6482-
$test_title = "unnamed";
6483-
}
6484-
}
6477+
$test_title = compute_title(\@ARGV, \@info_filenames)
6478+
unless $test_title;
64856479

64866480
if (@base_filenames) {
6481+
my @base_patterns = @base_filenames unless $baseline_title;
64876482
@base_filenames = AggregateTraces::find_from_glob(@base_filenames);
64886483

6489-
if (!$baseline_title) {
6490-
# use name of first file
6491-
$baseline_title = basename($base_filenames[0]);
6492-
}
6484+
$baseline_title = compute_title(\@base_patterns, \@base_filenames)
6485+
unless $baseline_title;
64936486
my $baseline_create;
64946487

64956488
if ($baseline_date) {
@@ -7389,6 +7382,27 @@ sub process_file($$$$$)
73897382
return ($testdata, $testfncdata, $testbrdata);
73907383
}
73917384

7385+
sub compute_title($$)
7386+
{
7387+
my ($patterns, $info_files) = @_;
7388+
7389+
my $title;
7390+
if (1 == scalar(@$info_files)) {
7391+
# just one coverage DB file
7392+
$title = basename($info_files->[0]);
7393+
} elsif (1 == scalar(@$patterns)) {
7394+
# just one pattern...
7395+
$title = $patterns->[0];
7396+
$title = substr($title, length($main::cwd) + 1)
7397+
if (File::Spec->file_name_is_absolute($title) &&
7398+
length($main::cwd) < length($title) &&
7399+
$main::cwd eq substr($title, 0, length($main::cwd)));
7400+
} else {
7401+
$title = scalar(@$info_files) . ' coverage DB files';
7402+
}
7403+
return $title;
7404+
}
7405+
73927406
#
73937407
# get_prefix(min_dir, filename_list)
73947408
#

0 commit comments

Comments
 (0)