Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 310 lines (231 sloc) 7.914 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
#!/usr/local/bin/perl

# Copyright 2001-2003, 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;

use Cwd;

use ExtUtils::MakeMaker;
use ExtUtils::Manifest "maniread";

$| = 1;

my $Version = "0.29";
my $Date = "19th December 2003";
my $Author = 'pjcj@cpan.org';

my @perlbug = ("perlbug", "-a", $Author,
                               "-s", "Installation of Devel::Cover $Version");
my $Perlbug = join " ", map { / / ? "'$_'" : $_ } @perlbug;

my @files = sort keys %{maniread()}, "lib/Devel/Cover/Inc.pm";
my @versions = grep { $_ ne "README" && $_ ne "Makefile.PL" } @files;

my $test_version = $ENV{__COVER_GOLDEN_VERSION} || $];

my $base = getcwd;

my %inc = map { $_ => 1 } @INC;
my @inc = sort keys %inc;

open I, ">lib/Devel/Cover/Inc.pm"
    or die "Cannot open lib/Devel/Cover/Inc.pm: $!";
print I <<"EOI";
# Copyright 2001-2003, 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

# This file was automatically generated by Makefile.PL.

package Devel::Cover::Inc;

use strict;
use warnings;

our \$VERSION = "$Version";
our \$Perl = '$^X';
our \$Base = '$base';
our \@Inc = qw( @inc );

1
EOI
close I or die "Cannot close lib/Devel/Cover/Inc.pm: $!";

print "Writing tests ........ ";

unless (-d "t")
{
    mkdir "t" or die "Cannot mkdir t: $!";
}

opendir D, "tests" or die "Cannot opendir tests: $!";
for my $t (readdir D)
{
    next unless -f "tests/$t";
    next if $t =~ /\.(pm|pl|version|org|bak)$/;
    next if $t =~ /~$/;
    open T, ">t/a$t.t" or die "Cannot open t/a$t.t: $!";
    print T <<EOT;
#!$^X

# Copyright 2002-2003, 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

use strict;
use warnings;

use lib "$base/lib";
use lib "$base/blib/lib";
use lib "$base/blib/arch";
use lib "$base/t";

use Devel::Cover::Test $Version;

my \$test = Devel::Cover::Test->new("$t");
\$test->run_test
EOT
    close T or die "Cannot open t/a$t.t: $!";
}
closedir D or die "Cannot closedir tests: $!";

print "done\n\n";

my $e;

print "checking for Storable.pm ........ ";

$e = <<EOM;

Storable.pm is required to store the coverage database. You can
download Storable from CPAN.

EOM

eval "use Storable";
if (my $m = $INC{"Storable.pm"})
{
    my $v = eval { no warnings; $Storable::VERSION };
    print "$v $m\n";
}
else
{
    print "not found\n\n$e\n";
}

print "checking for Digest::MD5.pm ........ ";

$e = <<EOM;

Digest::MD5.pm is required to check whether covered files have changed.
You can download Digest::MD5 from CPAN.

EOM

eval "use Digest::MD5";
if (my $m = $INC{"Digest/MD5.pm"})
{
    my $v = eval { no warnings; $Digest::MD5::VERSION };
    print "$v $m\n";
}
else
{
    print "not found\n\n$e\n";
}

print "checking for Template.pm version 2.00 ........ ";

$e = <<EOM;

Template.pm 2.00 is required to run the HTML backend to cover and for
cpancover. You will not be able to generate HTML output until you
install the Template Toolkit, available from CPAN. In the meantime you
may continue to use the rest of Devel::Cover.

EOM

eval "use Template";
if (my $m = $INC{"Template.pm"})
{
    my $v = eval { no warnings; $Template::VERSION };
    print $v < 2.00 ? "$v\n\n$e\n" : "$v $m\n";
}
else
{
    print "not found\n\n$e\n";
}

print "checking for Pod::Coverage.pm version 0.06 ........ ";

$e = <<EOM;

Pod::Coverage.pm 0.06 is required to do pod coverage. This will tell
you how well you have documented your modules. Pod coverage will be
unavailable until you install this module, available from CPAN. In the
meantime, you may continue to use the rest of Devel::Cover.
EOM

eval "use Pod::Coverage";
if (my $m = $INC{"Pod/Coverage.pm"})
{
    my $v = eval { no warnings; $Pod::Coverage::VERSION };
    print $v < 0.06 ? "$v\n\n$e\n" : "$v $m\n";
}
else
{
    print "not found\n\n$e\n";
}

my $latest_tested = 5.008002;
print <<EOM if $] > $latest_tested;

Devel::Cover $Version has not been tested with perl $].
Testing will take place against expected output from perl $latest_tested.
You may well find failing tests.

EOM

print "\n" x 3;

$ExtUtils::MakeMaker::Verbose = 0;

WriteMakefile
(
    NAME => "Devel::Cover",
    VERSION => $Version,
    AUTHOR => 'Paul Johnson (pjcj@cpan.org)',
    ABSTRACT => "Code coverage metrics for Perl",
    DIR => [],
    EXE_FILES => [ "cover", "gcov2perl" ],
    PREREQ_PM => {
                     Storable => 0,
                     "Digest::MD5" => 0,
                 },
    dist => { COMPRESS => "gzip --best --force" },
    clean => { FILES => join " ", "t/*", map "$_.version", @versions },
    realclean => { FILES => "lib/Devel/Cover/Inc.pm cover_db t" },
    depend => { distdir => "@files" },
);

print "\n";
print <<EOM if 0;

--------------------------------------------------------------------------------

I like to have some idea of the distribution of this software. To that end I
would be very grateful for mail from you. This will be used only to satisfy my
curiosity and to help me make decisions which may involve changes to the
module.

If you can run perlbug you can send me a success report with "make ok".
Failure reports with "make nok" are also appreciated.

If you have any questions or comments, mailing list details are available in the
README file, or send mail to me directly.

EOM

sub MY::libscan
{
    my ($self, $path) = @_;
    (my $p = $path) =~ s/^\$\(INST_LIB\)/lib/; # 5.6.1
    # print "$path $p\n";
    my $wanted = -d $p; # 5.9.0
    for my $f (@files)
    {
        last if $wanted ||= $p =~ /$f$/;
    }
    $wanted && $path;
}

sub MY::postamble
{
    qq[
SET_VERSION = \$(PERL) -pi.version \\
-e 's/(^\\s*(?:our\\s+)\\\$\$VERSION = ")\\d+\\.\\d+(";)/\$\${1}$Version\$\$2/;' \\
-e 's/(Version )\\d+\\.\\d+( - ).*/\$\${1}$Version\$\${2}$Date/;' \\
-e 's/(Devel::Cover Version )\\d+\\.\\d+/\$\${1}$Version/;' \\
-e 's/(\\buse Devel::Cover(?:::\\w+)*\\s+)\\d+\\.\\d+/\$\${1}$Version/;'

tags : @files
\t ptags @files

@versions : Makefile.PL
\t \$(SET_VERSION) @versions

README : lib/Devel/Cover.pm
\t TERMCAP= COLUMNS=80 pod2text lib/Devel/Cover.pm | \\
\$(PERL) -n \\
-e 'print if (/NAME/ ... /^[A-Z ]+\$\$/) =~ /^\\d+\$\$/;' \\
-e 'print if (/DESCRIPTION/ ... /^[A-Z ]+\$\$/) =~ /^\\d+\$\$/;' \\
> README

ppm : ppd pure_all
\t tar cf Devel-Cover.tar blib
\t gzip --best --force Devel-Cover.tar
\t \$(PERL) -pi.bak \\
-e 's/(OS NAME=")[^"]*/\$\$1MSWin32/;' \\
-e 's/(ARCHITECTURE NAME=")[^"]*/\$\$1MSWin32-x86-multi-thread/;' \\
-e 's/(CODEBASE HREF=")[^"]*/\$\$1Gedcom.tar.gz/;' \\
Devel-Cover.ppd

_run : pure_all
\t \$(PERL) -Mblib -MDevel::Cover=-ignore,blib,-merge,0,`\$(PERL) -e 'qx|grep __COVER__ \$\$ARGV[0]| =~ /__COVER__\\s+criteria\\s+(.*)/; (\$\$c = \$\$1 || "all") =~ s/\\s+/,/g; print "-coverage,\$\$c"' tests/\$(TEST)` tests/\$(TEST) && \\
\$(PERL) -Mblib cover -report text > \$(TEST).out

run : _run
\t \$(PERL) -Mblib cover && \\
gvim -d \$(TEST).out

__COVER_GOLDEN_VERSION ?= $test_version

diff : _run
\t gvim -d -font 8x13 test_output/cover/\$(TEST).\$(__COVER_GOLDEN_VERSION) \$(TEST).out

gold : pure_all
\t \$(PERL) create_gold \$(TEST)

ok :
\t \@$Perlbug -okay || echo "Please send your report manually to $Author"

nok :
\t \@$Perlbug -nokay || echo "Please send your report manually to $Author"
]
}
Something went wrong with that request. Please try again.