-
Notifications
You must be signed in to change notification settings - Fork 88
/
Makefile.PL
414 lines (327 loc) · 12.6 KB
/
Makefile.PL
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#!/usr/bin/perl ## no critic (ProhibitExcessMainComplexity)
# Copyright 2001-2024, Paul Johnson ([email protected])
# 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.012000;
use strict;
use warnings;
use Cwd;
use ExtUtils::MakeMaker;
use File::Copy;
require Data::Dumper;
local $| = 1;
my $Version = "1.44";
my $Latest_t = "5.040000";
my $Author = '[email protected]';
my $Inc_str = do {
my %inc
= map { -d () ? (($_ eq "." ? $_ : Cwd::abs_path($_)) => 1) : () } @INC;
my $dumper = Data::Dumper->new([ [ sort keys %inc ] ]);
$dumper->Indent(1)->Terse(1);
$dumper->Sortkeys(1) if $dumper->can("Sortkeys");
chomp(my $str = $dumper->Dump);
$str
};
open my $i, ">", "lib/Devel/Cover/Inc.pm"
or die "Cannot open lib/Devel/Cover/Inc.pm: $!";
print $i <<"EOI";
# Copyright 2001-2024, Paul Johnson (paul\@pjcj.net)
# 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_version = '$]';
our \@Inc = \@{ $Inc_str };
chomp (our \$Perl = <<'EOV'); # Careful with \\\\ in the path
$^X
EOV
if (\$Perl_version ne \$]) {
print STDERR <<"EOM";
This version of Devel::Cover was built with Perl version \$Perl_version.
It is now being run with Perl version \$].
Attempting to make adjustments, but you may find that some of your modules do
not have coverage data collected. You may need to alter the +-inc, +-ignore
and +-select options.
EOM
eval "use Cwd";
my \%inc =
map { -d \$_ ? ((\$_ eq "." ? \$_ : Cwd::abs_path(\$_)) => 1) : () } \@INC;
\@Inc = sort keys \%inc;
}
# TODO - check for threadedness, 64bits etc. ?
1
EOI
close $i or die "Cannot close lib/Devel/Cover/Inc.pm: $!";
print "Writing tests ........ ";
for my $d (qw( t t/e2e )) {
unless (mkdir $d) {
die "Cannot mkdir $d: $!" unless -d $d;
}
}
my @Tests;
opendir my $dir, "tests" or die "Cannot opendir tests: $!";
for my $t (readdir $dir) {
next unless -f "tests/$t";
next if $t =~ /\.(pm|pl|org|bak|uncoverable|swp)$/;
next if $t =~ /~$/;
push @Tests, $t;
if ($t =~ /\.t/) {
copy("tests/$t", "t/e2e/$t") or die "Cannot copy tests/$t to t/e2e/$t: $!";
next
}
open my $test, ">", "t/e2e/a$t.t" or die "Cannot open t/e2e/a$t.t: $!";
print $test <<EOT;
#!$^X
# Copyright 2002-2024, Paul Johnson (paul\@pjcj.net)
# 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 "./lib";
use lib "./blib/lib";
use lib "./blib/arch";
use lib "./t";
use Devel::Cover::Test;
my \$test = Devel::Cover::Test->new("$t");
\$test->run_test;
no warnings;
\$test # for create_gold
EOT
close $test or die "Cannot close t/e2e/a$t.t: $!";
}
closedir $dir or die "Cannot closedir tests: $!";
s/^/tests\// for @Tests;
push @Tests, grep !/e2e/, glob "t/*/*.t";
if ($ENV{DEVEL_COVER_NO_TESTS}) {
# don't run tests under p5cover
print "removing all tests with DEVEL_COVER_NO_TESTS\n";
system "rm -rf t/*"; # TODO portability
@Tests = ();
}
print "done\n\n";
my %Checked;
sub check {
my ($module, $text, $version) = @_;
printf "checking for %-18s %-16s .... ", $module,
$version ? "version $version" : "";
{
local $SIG{__WARN__} = sub { };
eval "use $module";
}
(my $mod = $module) =~ s/::/\//g;
if (my $m = $INC{"$mod.pm"}) {
## no critic (ProhibitNoWarnings, ProhibitStringyEval)
my $v = eval { no warnings; eval "\$${module}::VERSION" };
printf "%-8s $m\n", $v;
if ($version && $v < $version) {
print "\n\n\n$text\n" unless $Checked{$text}++;
print "\n";
}
} else {
print "not found";
print "\n\n\n$text\n" unless $Checked{$text}++;
print "\n";
}
}
my $D = <<EOM;
The coverage database can be stored in any of the Storable, JSON or Sereal
formats. To use the Storable format, the Storable module is required. This has
been a core module since perl-5.8.0. To store the database in JSON format
JSON::MaybeXS can be used. It will use the best JSON backend available, trying
first Cpanel::JSON::XS. To use the Sereal format, the Sereal module should be
installed. This is available on CPAN.
Sereal is used if it is available. Otherwise JSON is used, if available.
Otherwise Storable will be used. The Sereal and JSON formats should be portable
between all systems, whereas Storable format may not be.
EOM
check "Storable", $D;
check "JSON::MaybeXS", $D;
check "Sereal", $D;
check "Digest::MD5", <<EOM;
Digest::MD5 is required to check whether covered files have changed. You can
download Digest::MD5 from CPAN.
EOM
check "Test::More", <<EOM;
Test::More is required to run the Devel::Cover tests. You can download
Test::More from CPAN.
EOM
check "Template", <<EOM, "2.00";
Template 2.00 is required to run the some HTML backends to cover and for
cpancover. Unless you have specific requirements this should not be a problem,
but you will not be able to use these reports until you install the Template
Toolkit, available from CPAN. In the meantime you may continue to use the rest
of Devel::Cover.
EOM
my $M = <<EOM;
One of PPI::HTML 1.07 or Perl::Tidy 20060719 is required to add syntax
highlighting to some HTML backends to cover and for cpancover. Unless you have
specific requirements this should not be a problem, but you will not be able to
use syntax highlighting in these reports until you install PPI::HTML or
Perl::Tidy, available from the CPAN. However, the rest of Devel::Cover will be
available as usual.
EOM
check "PPI::HTML", $M, "1.07";
check "Perl::Tidy", $M, "20060719";
print "checking for Pod::Coverage version 0.06 .... ";
my $E = <<EOM;
Pod::Coverage 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"}) {
## no critic (ProhibitNoWarnings)
my $v = eval { no warnings; $Pod::Coverage::VERSION };
print $v < 0.06 ? "$v\n\n\n$E\n\n" : "$v $m\n";
print "checking for Pod::Coverage::CountParents .... ";
$E = <<EOM;
Pod::Coverage::CountParents.pm is used for Pod coverage if it is available. We
will fall back to using Pod::Coverage.pm. If you want to use
Pod::Coverage::CountParents.pm, just install it from CPAN.
EOM
eval "use Pod::Coverage::CountParents";
if (my $m = $INC{"Pod/Coverage/CountParents.pm"}) {
my $w = eval { no warnings; $Pod::Coverage::CountParents::VERSION };
$w ||= " ";
print "$w $m\n";
} else {
print "not found\n\n\n$E\n\n";
}
} else {
print "not found\n\n$E\n";
}
check "Test::Differences", <<EOM;
Test::Differences is used to display output from failed tests. Hopefully there
won't be any failed tests, but if there are you will get output that may not be
a model of clarity. If you do get test failures and you fancy helping me by
debugging them, then you might like to consider installing Test::Differences.
You can download Test::Differences from CPAN.
EOM
check "Browser::Open", <<EOM;
Browser::Open is used to launch a web browser when the -launch flag is specified
with HTML report formats. You can download Browser::Open from CPAN.
EOM
check "HTML::Entities", <<EOM;
HTML::Entities is used to run the HTML reports. If you would like to use the
HTML report, please install HTML::Entities. Otherwise, other reports will be
available as usual. Because HTML reports are expected, HTML::Entities has been
added to the prerequisites.
EOM
print <<EOM if $] > $Latest_t;
Devel::Cover $Version has not been tested with perl $].
Testing will take place against expected output from perl $Latest_t.
You may well find failing tests.
EOM
print "\n" x 3;
## no critic (ProhibitPackageVars)
$ExtUtils::MakeMaker::Verbose = 0;
my $Opts = {
NAME => "Devel::Cover",
VERSION => $Version,
AUTHOR => 'Paul Johnson <[email protected]>',
ABSTRACT_FROM => "lib/Devel/Cover.pm",
DIR => [],
EXE_FILES => [ map "bin/$_", qw( cover gcov2perl cpancover ) ],
PERL_MALLOC_OK => 1,
PREREQ_PM => {
"Storable" => 0,
"Digest::MD5" => 0,
"HTML::Entities" => 3.69,
$ENV{DEVEL_COVER_NO_TESTS} ? () : ("Test::More" => 0),
},
TYPEMAPS => ["utils/typemap"],
clean =>
{ FILES => "t/e2e/* cover_db* t/e2e/*cover_db " . "README *.gcov *.out" },
dist => { COMPRESS => "gzip --best --force" },
test => { TESTS => $ENV{DEVEL_COVER_NO_TESTS} ? "" : "t/*.t t/*/*.t" },
realclean => { FILES => "lib/Devel/Cover/Inc.pm cover_db t/e2e" },
};
# use Data::Dumper; print Dumper $Opts;
WriteMakefile(%$Opts);
print "\n";
sub MY::postamble {
my %tests;
@tests{@Tests} = map { (my $t = $_) =~ s/\W/_/g; "cover_db_$t" } @Tests;
my @reports = qw(
compilation html_basic html_minimal html html_subtle sort text2 text vim
);
qq[
tags : pure_all
\t ctags --recurse --exclude=blib --exclude=Devel-Cover-* .
show_version :
\t \@echo \$(VERSION)
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=")[^"]*/\$\$1Devel-Cover.tar.gz/;' \\
Devel-Cover.ppd
TAINT = -T
TAINT =
COVER_OPTIONS =
PERL5OPT =
_run : pure_all
\t \$(PERL) \$(TAINT) -Iblib/lib -Iblib/arch -MDevel::Cover=-merge,0,`\$(PERL) -e '\$\$l = qx|grep __COVER__ \$\$ARGV[0]|; \$\$l =~ /__COVER__\\s+criteria\\s+(.*)/; (\$\$c = \$\$1 || "all") =~ s/\\s+/,/g; \$\$p = "\$\$1," if \$\$l =~ /__COVER__\\s+test_parameters\\s+(.*)/; print "\$\$p-coverage,\$\$c"' tests/\$(TEST)`,\$(COVER_OPTIONS) tests/\$(TEST)
COVER_PARAMETERS = \$(PERL) -e '\$\$l = qx|grep __COVER__ \$\$ARGV[0]|; \$\$u = "-uncoverable_file \$\$1" if \$\$l =~ /__COVER__\\s+uncoverable_file\\s+(.*)/; (\$\$p) = \$\$l =~ /__COVER__\\s+cover_parameters\\s+(.*)/; print "\$\$u \$\$p"' tests/\$(TEST)
html : _run
\t \$(PERL) -Mblib bin/cover `\$(COVER_PARAMETERS)` -report html
basic : _run
\t \$(PERL) -Mblib bin/cover `\$(COVER_PARAMETERS)` -report html_basic
subtle : _run
\t \$(PERL) -Mblib bin/cover `\$(COVER_PARAMETERS)` -report html_subtle
out : _run
\t \$(PERL) -Mblib bin/cover `\$(COVER_PARAMETERS)` -report text > \$(TEST).out
text : out
\t \$(PAGER) \$(TEST).out
wrun : pure_all
\t \$(PERL) \$(TAINT) -Iblib/lib -Iblib/arch -MDevel::Cover=-ignore,blib,-merge,0 tests/\$(TEST)
prove : pure_all
\t \$(PERL) -Iutils -MDevel::Cover::BuildUtils=prove_command -le '\$\$c = prove_command and print \$\$c and system \$\$c'
t : pure_all
\t \$(PERL) -Mblib bin/cover -delete
\t exec make test HARNESS_OPTIONS=j`\$(PERL) -Iutils -MDevel::Cover::BuildUtils=nice_cpus -e 'print nice_cpus'`:c HARNESS_TIMER=1
no_replace_ops_t : pure_all
\t DEVEL_COVER_OPTIONS=-replace_ops,0 exec make t
DB = cover_db
dump :
\t \$(PERL) -Mblib bin/cover -dump_db \$(DB)
diff : out
\t \$(PERL) utils/makeh strip_criterion 'time' \$(TEST).out
\t \$(PERL) utils/makeh strip_criterion ' pod' \$(TEST).out
\t gold="`\$(PERL) -Mblib -MDevel::Cover::Test -e '\$\$t = Devel::Cover::Test->new(qq(\$(TEST))); print join qq(.), \$\$t->cover_gold'`" && \$(EDITOR) -d "\$\$gold" \$(TEST).out
gold : pure_all
\t \$(PERL) utils/create_gold \$(TEST)
all_test :
\t exec \$(PERL) utils/all_versions make t
all_gold :
\t \$(PERL) utils/create_all_gold \$(TEST)
_delete_db : pure_all
\t rm -rf cover_db
_self_cover_tests : @{[sort values %tests]}
\t DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover bin/cover -silent -write cover_db @{[sort values %tests]}
self_cover : _self_cover_reports
\t \$(PERL) -Mblib bin/cover -report html_basic -launch
\t \$(PERL) -Mblib bin/cover -report vim
] . "\n" . join "\n",
map("$tests{$_} : _delete_db\n"
. "\t \@echo Running $tests{$_}\n"
. "\t \@rm -rf $tests{$_}\n"
. "\t \@DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover=-db,$tests{$_},-silent,1,-coverage,all,-ignore,tests/,-coverage,pod-also_private-xx $_\n",
sort keys %tests),
"_self_cover_reports : @{[map qq(report_$_), @reports]}\n",
(
map "report_$_ : _self_cover_tests\n"
. "\t \@echo Generating $_ report\n"
. "\t \@DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover bin/cover -silent -report $_ > /dev/null\n",
@reports,
)
}