Permalink
Browse files

added -report_c0, -report_c1 and -report_c2 options to cover tool

  • Loading branch information...
1 parent 43fae73 commit 3be3626ed757565e22e5bb7251d17edef579fc5c @maspalio maspalio committed Mar 30, 2012
Showing with 53 additions and 6 deletions.
  1. +34 −0 bin/cover
  2. +10 −3 lib/Devel/Cover/Report/Html_basic.pm
  3. +9 −3 lib/Devel/Cover/Report/Html_minimal.pm
View
@@ -412,6 +412,40 @@ The following command line options are supported:
other options specific to the report
+=head1 REPORT FORMATS
+
+Tool accepts -report option:
+
+=over 4
+
+=item html|html_minimal (default)
+
+HTML reporting. Percentage thresholds are color-coded and configurable
+via -report_c0 <integer>, -report_c1 <integer> and -report_c2 <integer>.:
+
+ 0% 75% 90% 100%
+ | .. | .. | .. |
+ <=c0 <=c1 <c2 c3
+ green orange red
+
+=item html_basic
+
+HTML reporting with syntax highlighting if L<PPI::HTML> or L<Perl::Tidy>
+module is detected. Like html|html_minimal reporting, percentage thresholds
+are color-coded and configurable.
+
+=item text
+
+Plain text reporting.
+
+=item compilation
+
+Like text but hacked to give a minimal output in a format similar
+to that output by Perl itself so that it's easier to step through
+the untested locations with Emacs compilation mode.
+
+=back
+
=head1 DETAILS
Any number of coverage databases may be specified on the command line.
@@ -38,15 +38,17 @@ sub oclass
$o ? class($o->percentage, $o->error, $criterion) : ""
}
+my $threshold = { c0 => 75, c1 => 90, c2 => 100 };
+
sub class
{
my ($pc, $err, $criterion) = @_;
return "" if $criterion eq "time";
no warnings "uninitialized";
!$err ? "c3"
- : $pc < 75 ? "c0"
- : $pc < 90 ? "c1"
- : $pc < 100 ? "c2"
+ : $pc < $threshold->{c0} ? "c0"
+ : $pc < $threshold->{c1} ? "c1"
+ : $pc < $threshold->{c2} ? "c2"
: "c3"
}
@@ -380,7 +382,12 @@ sub get_options
GetOptions($opt->{option},
qw(
outputfile=s
+ report_c0=s
+ report_c1=s
+ report_c2=s
));
+ $threshold->{$_} = $opt->{option}{"report_$_"} for
+ grep { defined $opt->{option}{"report_$_"} } qw( c0 c1 c2 );
}
sub report
@@ -150,6 +150,7 @@ sub merge_lineops {
#===============================================================================
my %Filenames;
my @class = qw'c0 c1 c2 c3';
+my $threshold = { c0 => 75, c1 => 90, c2 => 100 };
#-------------------------------------------------------------------------------
# Subroutine : bclass()
@@ -169,9 +170,9 @@ sub bclass {
sub pclass {
my ($p, $e) = @_;
return $class[3] unless $e;
- $p < 75 && return $class[0];
- $p < 90 && return $class[1];
- $p < 100 && return $class[2];
+ $p < $threshold->{c0} && return $class[0];
+ $p < $threshold->{c1} && return $class[1];
+ $p < $threshold->{c2} && return $class[2];
$class[3]
}
@@ -682,7 +683,12 @@ sub get_options
pod!
summarytitle=s
unified!
+ report_c0=s
+ report_c1=s
+ report_c2=s
));
+ $threshold->{$_} = $opt->{option}{"report_$_"} for
+ grep { defined $opt->{option}{"report_$_"} } qw( c0 c1 c2 );
}

0 comments on commit 3be3626

Please sign in to comment.