Skip to content

Commit

Permalink
Make summary cover report respect options given.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcj committed Aug 2, 2012
1 parent 76bfe93 commit ad64145
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
21 changes: 13 additions & 8 deletions bin/cover
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,6 @@ sub main

print "\n\n" unless $Options->{silent};

$db->print_summary(@{$Options->{coverage}}) if $Options->{summary};

return unless length $Options->{report};

# TODO - The sense of select and ignore should be reversed to match
# collection.

Expand All @@ -355,14 +351,23 @@ sub main
};
@{$Options->{file}} = sort grep $keep->($_), keys %f;

$db->print_summary($Options->{file}, $Options->{coverage}, {force => 1})
if $Options->{summary};

return unless length $Options->{report};

$format->report($db, $Options);

if ($Options->{launch}) {
if ($format->can('launch')) {
if ($Options->{launch})
{
if ($format->can("launch"))
{
$format->launch($Options);
}
else {
print STDERR "launch not available for $Options->{report} reports\n"
else
{
print STDERR "The launch option is not available for the ",
"$Options->{report} report.\n"
}
}
}
Expand Down
19 changes: 14 additions & 5 deletions lib/Devel/Cover/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,21 @@ sub calculate_summary
return if exists $self->{summary} && !$options{force};
my $s = $self->{summary} = {};

for my $file ($self->cover->items)
my @files = $self->cover->items;
if (my $files = delete $options{files})
{
my %required_files = map { ($_ => 1) } @$files;
@files = grep $required_files{$_}, @files;
}

for my $file (@files)
{
$self->cover->get($file)->calculate_summary($self, $file, \%options);
}

# print STDERR Dumper $self;

for my $file ($self->cover->items)
for my $file (@files)
{
$self->cover->get($file)->calculate_percentage($self, $s->{$file});
}
Expand All @@ -397,15 +404,17 @@ sub trimmed_file
sub print_summary
{
my $self = shift;
my ($files, $criteria, $opts) = @_;

my %options = map(($_ => 1), @_ ? @_ : $self->collected);
my %options = map(($_ => 1), $criteria ? @$criteria : $self->collected);
$options{total} = 1 if keys %options;

my $n = keys %options;

my $oldfh = select STDOUT;

$self->calculate_summary(%options);
$options{files} = $files || [];
$self->calculate_summary(%options, %$opts);

my $format = sub
{
Expand Down Expand Up @@ -985,7 +994,7 @@ Devel::Cover::DB - Code coverage metrics for Perl
use Devel::Cover::DB;
my $db = Devel::Cover::DB->new(db => "my_coverage_db");
$db->print_summary(statement => 1, pod => 1);
$db->print_summary([$file1, $file2], ["statement", "pod"]);
$db->print_details;
=head1 DESCRIPTION
Expand Down

0 comments on commit ad64145

Please sign in to comment.