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 ****
--- 51,57 ----
use strict; use strict;
use File::Basename; use File::Basename;
+ use Cwd qw(abs_path); +use Cwd qw(abs_path);
use Getopt::Long; use File::Spec::Functions qw /abs2rel catdir file_name_is_absolute splitdir
use Digest::MD5 qw(md5_base64); splitpath rel2abs/;
use Getopt::Long;
@@ -95,6 +96,7 @@ sub match_filename($@);
sub solve_ambiguous_match($$$);
sub split_filename($);
sub solve_relative_path($$);
+sub find_source_file($$);
sub read_gcov_header($);
sub read_gcov_file($);
sub info(@);
@@ -964,7 +966,7 @@ sub process_dafile($$)
*************** if (defined($source))
*** 81,86 **** {
--- 82,88 ---- - $source = solve_relative_path($base_dir, $source);
sub solve_ambiguous_match($$$); + $source = find_source_file($base_dir, $source);
sub split_filename($); }
sub solve_relative_path($$);
+ sub find_source_file($$);
sub get_dir($);
sub read_gcov_header($);
sub read_gcov_file($);
***************
*** 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
{ - if (!@matches)
! $source = find_source_file($base_dir, $source); - {
} - warn("WARNING: cannot find an entry for ".$gcov_file.
- " in $graph_file_extension file, skipping ".
- "file!\n");
- unlink($gcov_file);
- next;
- }
+ @matches = ($source);
# gcov will happily create output even if there's no source code # Read in contents of gcov file
*************** @result = read_gcov_file($gcov_file);
*** 741,758 **** @@ -1242,6 +1235,25 @@ sub solve_relative_path($$)
die("ERROR: could not read source file $source\n"); }
}
! @matches = match_filename(defined($source) ? $source :
! $gcov_file, keys(%bb_content));
# Skip files that are not mentioned in the graph file
! if (!@matches)
! {
! warn("WARNING: cannot find an entry for ".$gcov_file.
! " in $graph_file_extension file, skipping ".
! "file!\n");
! unlink($gcov_file);
! next;
! }
# Read in contents of gcov file
@result = read_gcov_file($gcov_file);
--- 743,764 ----
die("ERROR: could not read source file $source\n");
}
! next if ! -r $source;
!
! #@matches = match_filename(defined($source) ? $source :
! # $gcov_file, keys(%bb_content));
# Skip files that are not mentioned in the graph file
! #if (!@matches)
! #{
! # warn("WARNING: cannot find an entry for ".$gcov_file.
! # " in $graph_file_extension file, skipping ".
! # "file!\n");
! # unlink($gcov_file);
! # next;
! #}
!
! @matches = ($source);
# Read in contents of gcov file
@result = read_gcov_file($gcov_file);
***************
*** 949,954 ****
--- 955,979 ----
}
+ sub find_source_file($$) +sub find_source_file($$)
+ { +{
+ my ($base_dir, $source) = @_; + my ($base_dir, $source) = @_;
+ my $dir = $base_dir; + my $dir = $base_dir;
+ +
+ # Hack to make absolute paths work on Nixpkgs coverage + # Hack to make absolute paths work on Nixpkgs coverage
+ # reports. The source is in /nix/store/<bla>/.build/<bla>. + # reports. The source is in /nix/store/<bla>/.build/<bla>.
+ $source = $1 if $source =~ /^\/.*\/\.build\/(.*)$/; + $source = $1 if $source =~ /^\/.*\/\.build\/(.*)$/;
+ +
+ while (!-e "$dir/$source") { + while (!-e "$dir/$source") {
+ $dir = $dir . "/.."; + $dir = $dir . "/..";
+ if (length $dir > 1000) { + if (length $dir > 1000) {
+ return "$base_dir/$source"; + return "$base_dir/$source";
+ } + }
+ } + }
+ return abs_path("$dir/$source"); + return abs_path("$dir/$source");
+ } +}
+ +
+ +
# #
# match_filename(gcov_filename, list) # match_filename(gcov_filename, list)
# #
*************** @@ -1918,7 +1930,7 @@ sub process_graphfile($$)
*** 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); # Get path to data file in absolute and normalized form (begins with /,
$lineno = unpack_int32($packed_word, $endianness); # contains no more ../ or ./)
--- 1503,1509 ---- - $graph_filename = solve_relative_path($cwd, $graph_filename);
$function_name =~ s/\W/_/g; + $graph_filename = find_source_file($cwd, $graph_filename);
(undef, $filename) =
read_gcno_string(*INPUT, $endianness); # Get directory and basename of data file
! $filename = find_source_file($base_dir, $filename); ($graph_dir, $graph_basename) = split_filename($graph_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}))
{