LCOV 1.8.

svn path=/nixpkgs/trunk/; revision=21149
This commit is contained in:
Ludovic Courtès 2010-04-18 21:51:33 +00:00
parent 502f979532
commit aa0902047e
2 changed files with 103 additions and 151 deletions

View File

@ -1,11 +1,11 @@
{stdenv, fetchurl, perl}: {stdenv, fetchurl, perl}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "lcov-1.7"; name = "lcov-1.8";
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/ltp/${name}.tar.gz"; url = "mirror://sourceforge/ltp/${name}.tar.gz";
sha256 = "1cx3haizs0rw6wjsn486qcn50f3qpybflkkb1780cg6s8jzcwdin"; sha256 = "1xrd9abh1gyki9ln9v772dq7jinvyrvx39s3kxbpiila68mbpa7j";
}; };
patches = [ ./find-source.patch ]; patches = [ ./find-source.patch ];
@ -19,13 +19,26 @@ stdenv.mkDerivation rec {
''; '';
postInstall = '' postInstall = ''
for i in $out/bin/*; do for i in "$out/bin/"*; do
substituteInPlace $i --replace /usr/bin/perl ${perl}/bin/perl substituteInPlace $i --replace /usr/bin/perl ${perl}/bin/perl
done done
''; # */ '';
meta = { meta = {
description = "A code coverage tool for Linux"; description = "LCOV, a code coverage tool that enhances GNU gcov";
longDescription =
'' LCOV is an extension of GCOV, a GNU tool which provides information
about what parts of a program are actually executed (i.e.,
"covered") while running a particular test case. The extension
consists of a set of PERL scripts which build on the textual GCOV
output to implement the following enhanced functionality such as
HTML output.
'';
homepage = http://ltp.sourceforge.net/coverage/lcov.php; homepage = http://ltp.sourceforge.net/coverage/lcov.php;
license = "GPLv2+";
maintainers = [ stdenv.lib.maintainers.ludo ];
}; };
} }

View File

@ -1,145 +1,84 @@
diff --exclude '*~' -rc lcov-1.7-orig/bin/geninfo lcov-1.7/bin/geninfo --- lcov-1.8/bin/geninfo 2010-01-29 11:14:46.000000000 +0100
*** lcov-1.7-orig/bin/geninfo 2008-11-17 14:50:26.000000000 +0100 +++ lcov-1.8/bin/geninfo 2010-04-18 23:33:43.000000000 +0200
--- lcov-1.7/bin/geninfo 2009-09-02 10:55:25.000000000 +0200 @@ -51,6 +51,7 @@
***************
*** 51,56 **** use strict;
--- 51,57 ---- use File::Basename;
+use Cwd qw(abs_path);
use strict; use File::Spec::Functions qw /abs2rel catdir file_name_is_absolute splitdir
use File::Basename; splitpath rel2abs/;
+ use Cwd qw(abs_path); use Getopt::Long;
use Getopt::Long; @@ -95,6 +96,7 @@ sub match_filename($@);
use Digest::MD5 qw(md5_base64); sub solve_ambiguous_match($$$);
sub split_filename($);
*************** sub solve_relative_path($$);
*** 81,86 **** +sub find_source_file($$);
--- 82,88 ---- sub read_gcov_header($);
sub solve_ambiguous_match($$$); sub read_gcov_file($);
sub split_filename($); sub info(@);
sub solve_relative_path($$); @@ -964,7 +966,7 @@ sub process_dafile($$)
+ sub find_source_file($$);
sub get_dir($); if (defined($source))
sub read_gcov_header($); {
sub read_gcov_file($); - $source = solve_relative_path($base_dir, $source);
*************** + $source = find_source_file($base_dir, $source);
*** 724,730 **** }
if (defined($source)) # gcov will happily create output even if there's no source code
{ @@ -981,18 +983,9 @@ sub process_dafile($$)
! $source = solve_relative_path($base_dir, $source); die("ERROR: could not read source file $source\n");
} }
# gcov will happily create output even if there's no source code - @matches = match_filename(defined($source) ? $source :
--- 726,732 ---- - $gcov_file, keys(%{$instr}));
+ next if ! -r $source;
if (defined($source))
{ - # Skip files that are not mentioned in the graph file
! $source = find_source_file($base_dir, $source); - if (!@matches)
} - {
- warn("WARNING: cannot find an entry for ".$gcov_file.
# gcov will happily create output even if there's no source code - " in $graph_file_extension file, skipping ".
*************** - "file!\n");
*** 741,758 **** - unlink($gcov_file);
die("ERROR: could not read source file $source\n"); - next;
} - }
+ @matches = ($source);
! @matches = match_filename(defined($source) ? $source :
! $gcov_file, keys(%bb_content)); # Read in contents of gcov file
@result = read_gcov_file($gcov_file);
# Skip files that are not mentioned in the graph file @@ -1242,6 +1235,25 @@ sub solve_relative_path($$)
! if (!@matches) }
! {
! warn("WARNING: cannot find an entry for ".$gcov_file.
! " in $graph_file_extension file, skipping ". +sub find_source_file($$)
! "file!\n"); +{
! unlink($gcov_file); + my ($base_dir, $source) = @_;
! next; + my $dir = $base_dir;
! } +
+ # Hack to make absolute paths work on Nixpkgs coverage
# Read in contents of gcov file + # reports. The source is in /nix/store/<bla>/.build/<bla>.
@result = read_gcov_file($gcov_file); + $source = $1 if $source =~ /^\/.*\/\.build\/(.*)$/;
--- 743,764 ---- +
die("ERROR: could not read source file $source\n"); + while (!-e "$dir/$source") {
} + $dir = $dir . "/..";
+ if (length $dir > 1000) {
! next if ! -r $source; + return "$base_dir/$source";
! + }
! #@matches = match_filename(defined($source) ? $source : + }
! # $gcov_file, keys(%bb_content)); + return abs_path("$dir/$source");
+}
# Skip files that are not mentioned in the graph file +
! #if (!@matches) +
! #{ #
! # warn("WARNING: cannot find an entry for ".$gcov_file. # match_filename(gcov_filename, list)
! # " in $graph_file_extension file, skipping ". #
! # "file!\n"); @@ -1918,7 +1930,7 @@ sub process_graphfile($$)
! # unlink($gcov_file);
! # next; # Get path to data file in absolute and normalized form (begins with /,
! #} # contains no more ../ or ./)
! - $graph_filename = solve_relative_path($cwd, $graph_filename);
! @matches = ($source); + $graph_filename = find_source_file($cwd, $graph_filename);
# Read in contents of gcov file # Get directory and basename of data file
@result = read_gcov_file($gcov_file); ($graph_dir, $graph_basename) = split_filename($graph_filename);
***************
*** 949,954 ****
--- 955,979 ----
}
+ sub find_source_file($$)
+ {
+ my ($base_dir, $source) = @_;
+ my $dir = $base_dir;
+
+ # Hack to make absolute paths work on Nixpkgs coverage
+ # reports. The source is in /nix/store/<bla>/.build/<bla>.
+ $source = $1 if $source =~ /^\/.*\/\.build\/(.*)$/;
+
+ while (!-e "$dir/$source") {
+ $dir = $dir . "/..";
+ if (length $dir > 1000) {
+ return "$base_dir/$source";
+ }
+ }
+ return abs_path("$dir/$source");
+ }
+
+
#
# match_filename(gcov_filename, list)
#
***************
*** 1478,1484 ****
$function_name =~ s/\W/_/g;
(undef, $filename) =
read_gcno_string(*INPUT, $endianness);
! $filename = solve_relative_path($base_dir, $filename);
read(INPUT, $packed_word, 4);
$lineno = unpack_int32($packed_word, $endianness);
--- 1503,1509 ----
$function_name =~ s/\W/_/g;
(undef, $filename) =
read_gcno_string(*INPUT, $endianness);
! $filename = find_source_file($base_dir, $filename);
read(INPUT, $packed_word, 4);
$lineno = unpack_int32($packed_word, $endianness);
***************
*** 1530,1536 ****
}
if ($blocks > 1)
{
! $filename = solve_relative_path(
$base_dir, $filename);
if (!defined($result{$filename}))
{
--- 1555,1561 ----
}
if ($blocks > 1)
{
! $filename = find_source_file(
$base_dir, $filename);
if (!defined($result{$filename}))
{