Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make summary cover report respect options given.

  • Loading branch information...
commit ad6414527b4188d72281761601a8da6b9ce2b81a 1 parent 76bfe93
@pjcj authored
Showing with 27 additions and 13 deletions.
  1. +13 −8 bin/cover
  2. +14 −5 lib/Devel/Cover/DB.pm
View
21 bin/cover
@@ -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.
@@ -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"
}
}
}
View
19 lib/Devel/Cover/DB.pm
@@ -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});
}
@@ -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
{
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.