Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'report_cs' of https://github.com/maspalio/Devel--Cover

…into report_cs
  • Loading branch information...
commit faba2b8e33acdbb49cd4b49b769598d980d402a6 2 parents 28d7445 + 17e2898
@pjcj authored
View
42 bin/cover
@@ -41,6 +41,9 @@ my $Options =
report => "",
summary => 1,
uncoverable_file => [".uncoverable", glob("~/.uncoverable")],
+ report_c0 => 75,
+ report_c1 => 90,
+ report_c2 => 100,
};
sub get_options
@@ -75,6 +78,9 @@ sub get_options
test!
uncoverable_file=s
version|v!
+ report_c0=s
+ report_c1=s
+ report_c2=s
));
Getopt::Long::Configure("nopass_through");
$Options->{report} ||= "html" unless exists $Options->{write};
@@ -410,7 +416,41 @@ The following command line options are supported:
-gcov - run gcov to cover XS code (default on if using gcc)
-make make_prog - use the given 'make' program for 'make test'
- other options specific to the report
+ other options specific to the report format
+
+=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
+ red yellow orange green
+
+=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
View
26 lib/Devel/Cover/Report/Html_basic.pm
@@ -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"
}
@@ -376,6 +378,8 @@ sub get_options
{
my ($self, $opt) = @_;
$opt->{option}{outputfile} = "coverage.html";
+ $threshold->{$_} = $opt->{"report_$_"} for
+ grep { defined $opt->{"report_$_"} } qw( c0 c1 c2 );
die "Invalid command line options" unless
GetOptions($opt->{option},
qw(
@@ -534,6 +538,22 @@ $Templates{summary} = <<'EOT';
<td class="sh" align="right">Report date:</td>
<td class="sv" align="left">[% R.date %]</td>
</tr>
+ <tr>
+ <td class="sh" align="right">C0:</td>
+ <td class="sv c0" align="left">&lt;&nbsp;[% R.options.report_c0 %]%</td>
+ </tr>
+ <tr>
+ <td class="sh" align="right">C1:</td>
+ <td class="sv c1" align="left">&lt;&nbsp;[% R.options.report_c1 %]%</td>
+ </tr>
+ <tr>
+ <td class="sh" align="right">C2:</td>
+ <td class="sv c2" align="left">&lt;&nbsp;[% R.options.report_c2 %]%</td>
+ </tr>
+ <tr>
+ <td class="sh" align="right">C3:</td>
+ <td class="sv c3" align="left">&gt;=&nbsp;[% R.options.report_c2 %]%</td>
+ </tr>
</table>
<div><br></br></div>
<table class="sortable" id="coverage_table">
View
33 lib/Devel/Cover/Report/Html_minimal.pm
@@ -4,6 +4,7 @@ use strict;
use warnings;
use CGI;
use Getopt::Long;
+use Devel::Cover;
use Devel::Cover::DB;
use Devel::Cover::Truth_Table;
@@ -150,6 +151,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 +171,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]
}
@@ -255,13 +257,15 @@ sub print_html_header {
my $fh = shift;
my $title = shift;
+ my $version = Devel::Cover->version;
+
print $fh <<"END_HTML";
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
-This file was generated by Devel::Cover Version $VERSION
+This file was generated by Devel::Cover Version $version
Devel::Cover is copyright 2001-2011, Paul Johnson (pjcj\@cpan.org)
Devel::Cover is free. It is licensed under the same terms as Perl itself.
The latest version of Devel::Cover should be available from my homepage:
@@ -364,7 +368,21 @@ sub print_summary_report {
<body>
<h1>$options->{option}{summarytitle}</h1>
<table>
-<tr><td class="h" align="right">Database:</td><td align="left">$db->{db}</td></tr>
+ <tr>
+ <td class="h" align="right">Database:</td><td align="left">$db->{db}</td>
+ </tr>
+ <tr>
+ <td class="h" align="right">C0:</td><td class="c0" align="left">&lt;&nbsp;$options->{report_c0}\%</td>
+ </tr>
+ <tr>
+ <td class="h" align="right">C1:</td><td class="c1" align="left">&lt;&nbsp;$options->{report_c1}\%</td>
+ </tr>
+ <tr>
+ <td class="h" align="right">C2:</td><td class="c2" align="left">&lt;&nbsp;$options->{report_c2}\%</td>
+ </tr>
+ <tr>
+ <td class="h" align="right">C3:</td><td class="c3" align="left">&gt;=&nbsp;$options->{report_c2}\%</td>
+ </tr>
</table>
<div><br/></div>
<table>
@@ -674,6 +692,8 @@ sub get_options
$opt->{option}{pod} = 1;
$opt->{option}{outputfile} = "coverage.html";
$opt->{option}{summarytitle} = "Coverage Summary";
+ $threshold->{$_} = $opt->{"report_$_"} for
+ grep { defined $opt->{"report_$_"} } qw( c0 c1 c2 );
die "Invalid command line options" unless
GetOptions($opt->{option},
qw(
@@ -682,6 +702,9 @@ sub get_options
pod!
summarytitle=s
unified!
+ report_c0=s
+ report_c1=s
+ report_c2=s
));
}
Please sign in to comment.
Something went wrong with that request. Please try again.