Skip to content

Commit

Permalink
import Devel::Cover 0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcj committed Nov 3, 2004
1 parent 34f3dd2 commit f9ee5ec
Show file tree
Hide file tree
Showing 27 changed files with 349 additions and 71 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Expand Up @@ -109,3 +109,8 @@ Release 0.18 - 28th September 2002

Release 0.19 - 29th September 2002
- Quieten uninitialised value warnings.

Release 0.20 - 5th October 2002
- Add break after default to satisfy IBM's xlC compiler on AIX.
- Get things working with threads again.
- make realclean is.
5 changes: 3 additions & 2 deletions Cover.xs
Expand Up @@ -212,7 +212,7 @@ static OP *get_condition(pTHX)
AV *conds;
SV **sv;
OP *op;
OP *(*f)(pTHX_);
OP *(*f)(pTHX);
I32 i;

NDEB(D(L, "In get_condition\n"));
Expand All @@ -226,7 +226,7 @@ static OP *get_condition(pTHX)
NDEB(D(L, "Looking through %d conditionals\n", av_len(conds)));

sv = av_fetch(conds, 0, 0);
f = (OP *(*)(pTHX_)) SvIV(*sv);
f = (OP *(*)(pTHX)) SvIV(*sv);

for (i = 1; i <= av_len(conds); i++)
{
Expand Down Expand Up @@ -526,6 +526,7 @@ static int runops_cover(pTHX)
}

default:
; /* IBM's xlC compiler on AIX is very picky */
}
}

Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -25,6 +25,7 @@ lib/Devel/Cover/Report/Html.pm
cover
gcov2perl
create_gold
cpancover
tests/t0
tests/t1
tests/t2
Expand Down
5 changes: 3 additions & 2 deletions Makefile.PL
Expand Up @@ -18,8 +18,8 @@ use ExtUtils::MakeMaker;

$| = 1;

my $Version = "0.19";
my $Date = "29th September 2002";
my $Version = "0.20";
my $Date = "5th October 2002";
my $Author = 'pjcj@cpan.org';

my @perlbug = ("perlbug", "-a", $Author,
Expand Down Expand Up @@ -164,6 +164,7 @@ WriteMakefile
EXE_FILES => [ "cover", "gcov2perl" ],
dist => { COMPRESS => "gzip --best --force" },
clean => { FILES => join " ", map { "$_.version" } @versions },
realclean => { FILES => "lib/Devel/Cover/Inc.pm cover_db t" },
depend => { distdir => "@files" },
);

Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -6,7 +6,7 @@ DESCRIPTION

If you can't guess by the version number this is an alpha release.

Code coverage data are collected using a plugable runops function which
Code coverage data are collected using a pluggable runops function which
counts how many times each op is executed. These data are then mapped
back to reality using the B compiler modules. There is also a statement
profiling facility which needs a better backend to be really useful.
Expand Down
19 changes: 16 additions & 3 deletions cover
Expand Up @@ -12,9 +12,9 @@ require 5.6.1;
use strict;
use warnings;

our $VERSION = "0.19";
our $VERSION = "0.20";

use Devel::Cover::DB 0.19;
use Devel::Cover::DB 0.20;

use Getopt::Long;

Expand All @@ -23,6 +23,7 @@ use Pod::Usage;
my $Options =
{
coverage => [],
delete => 0,
file => [],
option => [],
report => "",
Expand All @@ -39,6 +40,7 @@ sub get_options
},
qw(
coverage=s
delete!
help|h!
file=s
info|i!
Expand Down Expand Up @@ -71,6 +73,17 @@ sub main

my $dbname = shift @ARGV || "cover_db";

if ($Options->{delete})
{
for my $del ($dbname, @ARGV)
{
print "Deleting database $dbname\n";
my $db = Devel::Cover::DB->new(db => $dbname);
$db->delete;
}
exit 0;
}

print "Reading database from $dbname\n";
my $db = Devel::Cover::DB->new(db => $dbname);

Expand Down Expand Up @@ -185,7 +198,7 @@ Huh?
=head1 VERSION
Version 0.19 - 29th September 2002
Version 0.20 - 5th October 2002
=head1 LICENCE
Expand Down
242 changes: 242 additions & 0 deletions cpancover
@@ -0,0 +1,242 @@
#!/usr/local/bin/perl

# Copyright 2002, Paul Johnson (pjcj@cpan.org)

# This software is free. It is licensed under the same terms as Perl itself.

# The latest version of this software should be available from my homepage:
# http://www.pjcj.net

require 5.6.1;

use strict;
use warnings;

our $VERSION = "0.20";

use Cwd;
use File::Find ();
use Getopt::Long;
use Pod::Usage;

my $Options =
{
cover_source => "/home/pjcj/g/perl/dev/Devel/Cover",
directory => getcwd,
module => [],
outputdir => getcwd,
};

sub get_options
{
die "Bad option" unless
GetOptions($Options, # Store the options in the Options hash.
qw(
cover_source=s
directory=s
help|h!
info|i!
module=s
outputdir=s
version|v!
));

print "$0 version $VERSION\n" and exit 0 if $Options->{version};
pod2usage(-exitval => 0, -verbose => 0) if $Options->{help};
pod2usage(-exitval => 0, -verbose => 2) if $Options->{info};

push @{$Options->{module}}, @ARGV;
unless (@{$Options->{module}})
{
my $d = $Options->{directory};
opendir D, $d or die "Can't opendir $d: $!\n";
@{$Options->{module}} = grep !/^\./ && -e "$d/$_/Makefile.PL",
sort readdir D
or die "No module directories found\n";
closedir D or die "Can't closedir $d: $!\n";
}
}

sub sys
{
my ($command) = @_;
print "$command\n";
system $command;
}

sub read_results
{
my $f = "$Options->{outputdir}/cover.results";
my %results;

if (open S, "<", $f)
{
while (<S>)
{
my ($mod, $status) = split;
$results{$mod} = $status;
}
close S or die "Can't close $f: $!\n";
}

\%results
}

sub get_cover
{
my ($module) = @_;

print "\n\n\n**** Checking coverage of $module ****\n\n\n";

my $d = "$Options->{directory}/$module";
chdir $d or die "Can't chdir $d: $!\n";

my $s = $Options->{cover_source};
my $inc = "-I$s/blib/lib -I$s/blib/arch";
$ENV{HARNESS_PERL_SWITCHES} =
"$inc -MDevel::Cover=+inc,$s,-ignore,\\\\bt/,-silent,1";

# sys "$^X $inc $s/cover -delete";
# sys "make test";

my $func = sub
{
sys "$^X $inc $s/cover -report html" if -d && /^cover_db\z/s;
};

File::Find::find($func, $d);

my $results = read_results;
my $f = "$Options->{outputdir}/cover.results";

$results->{$module} = 1;

open S, ">", $f or die "Can't open $f: $!\n";
for my $mod (sort keys %$results)
{
print S "$mod $results->{$mod}\n";
}
close S or die "Can't close $f: $!\n";
}

sub write_html
{
my $results = read_results;
my $f = "$Options->{outputdir}/cpancover.html";
print "Writing results to $f\n";

open S, ">", $f or die "Can't open $f: $!\n";
print S <<'EOH';
<!--
This file was generated by Devel::Cover Version 0.20
Devel::Cover is copyright 2001-2002, 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:
http://www.pjcj.net
-->
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<title> Coverage Report </title>
</head>
<body>
EOH

my $func = sub
{
if (/^cover_db\.html\z/s)
{
my $d = $File::Find::dir;
$d =~ s|/cover_db$||;
print S "<a href=$File::Find::name>$d</a><p>\n"
}
};

for my $mod (sort keys %$results)
{
File::Find::find($func, $mod);
}

print S <<EOH;
</body>
</html>
EOH

close S or die "Can't close $f: $!\n";
}

sub main
{
get_options;

# get_cover($_) for @{$Options->{module}}

write_html;
}

main

__END__
=head1 NAME
cpancover - report coverage statistics on CPAN modules
=head1 SYNOPSIS
cpancover -help -info -version
=head1 DESCRIPTION
=head1 OPTIONS
The following command line options are supported:
-h -help - show help
-i -info - show documentation
-v -version - show version
=head1 DETAILS
=head1 EXIT STATUS
The following exit values are returned:
0 All operaions were completed successfully.
>0 An error occurred.
=head1 SEE ALSO
Devel::Cover
=head1 BUGS
Incomplete.
Needs to be redone properly.
=head1 VERSION
Version 0.20 - 5th October 2002
=head1 LICENCE
Copyright 2001-2002, Paul Johnson (pjcj@cpan.org)
This software is free. It is licensed under the same terms as Perl itself.
The latest version of this software should be available from my homepage:
http://www.pjcj.net
=cut
4 changes: 2 additions & 2 deletions create_gold
Expand Up @@ -12,11 +12,11 @@ require 5.6.1;
use strict;
use warnings;

our $VERSION = "0.19";
our $VERSION = "0.20";

use blib;

use Devel::Cover::Test 0.19;
use Devel::Cover::Test 0.20;

my @tests = @ARGV;

Expand Down

0 comments on commit f9ee5ec

Please sign in to comment.