Skip to content

Commit 2a634f6

Browse files
Philip Withnalloberpar
authored andcommitted
genhtml: Support relative source filenames in SF keys
Some tools which generate .info files generate relative filenames for the ‘SF’ keys. For example, nodeunit’s lcov output does. When genhtml is run with --output-directory, it calls chdir() which breaks relative lookup of the source files. Fix that by resolving all source filenames to absolute paths when loading an info file, resolving any relative ones using the info file’s path as a base. Signed-off-by: Philip Withnall <[email protected]>
1 parent b4344c6 commit 2a634f6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bin/genhtml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,7 @@ sub read_info_file($)
14761476
my $line_checksum; # Checksum of current line
14771477
my $br_found;
14781478
my $br_hit;
1479+
my $notified_about_relative_paths;
14791480
local *INFO_HANDLE; # Filehandle for .info file
14801481

14811482
info("Reading data file $tracefile\n");
@@ -1542,7 +1543,16 @@ sub read_info_file($)
15421543
{
15431544
# Filename information found
15441545
# Retrieve data for new entry
1545-
$filename = $1;
1546+
$filename = File::Spec->rel2abs($1, Cwd::cwd());
1547+
1548+
if (!File::Spec->file_name_is_absolute($1) &&
1549+
!$notified_about_relative_paths)
1550+
{
1551+
info("Resolved relative source file ".
1552+
"path \"$1\" with CWD to ".
1553+
"\"$filename\".\n");
1554+
$notified_about_relative_paths = 1;
1555+
}
15461556

15471557
$data = $result{$filename};
15481558
($testdata, $sumcount, $funcdata, $checkdata,

0 commit comments

Comments
 (0)