Skip to content

Commit

Permalink
Improve self_cover make target.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcj committed Sep 20, 2010
1 parent 2e1e885 commit 3c3aa91
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions Makefile.PL
Expand Up @@ -94,13 +94,16 @@ for my $d (qw( t t/e2e ))
} }
} }


my @tests;
opendir D, "tests" or die "Cannot opendir tests: $!"; opendir D, "tests" or die "Cannot opendir tests: $!";
for my $t (readdir D) for my $t (readdir D)
{ {
next unless -f "tests/$t"; next unless -f "tests/$t";
next if $t =~ /\.(pm|pl|org|bak|uncoverable)$/; next if $t =~ /\.(pm|pl|org|bak|uncoverable)$/;
next if $t =~ /~$/; next if $t =~ /~$/;


push @tests, $t;

if ($t =~ /\.t/) if ($t =~ /\.t/)
{ {
copy("tests/$t", "t/e2e/$t") or die "Cannot copy tests/$t to t/e2e/$t: $!"; copy("tests/$t", "t/e2e/$t") or die "Cannot copy tests/$t to t/e2e/$t: $!";
Expand Down Expand Up @@ -134,6 +137,9 @@ EOT
} }
closedir D or die "Cannot closedir tests: $!"; closedir D or die "Cannot closedir tests: $!";


s/^/tests\// for @tests;
push @tests, grep !/e2e/, <t/*/*.t>;

print "done\n\n"; print "done\n\n";


my $e; my $e;
Expand Down Expand Up @@ -428,6 +434,9 @@ sub MY::libscan


sub MY::postamble sub MY::postamble
{ {
my %tests;
@tests{@tests} = map { (my $t = $_) =~ s/\W/_/g; "cover_db_$t" } @tests;

qq[ qq[
SET_VERSION = \$(PERL) -pi \\ SET_VERSION = \$(PERL) -pi \\
-e 's/(^\\s*(?:our\\s+)\\\$\$VERSION = ")\\d+\\.\\d+(";)/\$\${1}$Version\$\$2/;' \\ -e 's/(^\\s*(?:our\\s+)\\\$\$VERSION = ")\\d+\\.\\d+(";)/\$\${1}$Version\$\$2/;' \\
Expand Down Expand Up @@ -511,13 +520,18 @@ all_gold :
\t rm -rf test_output \t rm -rf test_output
\t exec \$(PERL) utils/all_versions make gold \t exec \$(PERL) utils/all_versions make gold
self_cover : pure_all _delete_db : pure_all
\t rm -rf cover_db \t rm -rf cover_db
\t -DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover cover -delete t/e2e/cover_db_*
\t -DEVEL_COVER_SELF=1 make test _self_cover : @{[sort values %tests]}
\t DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover cover t/e2e/cover_db_* \t DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover cover -write cover_db @{[sort values %tests]}
\t DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover cover
\t DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover cover -report text > /dev/null
\t DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover cover -report html_basic \t DEVEL_COVER_SELF=1 \$(PERL) -Mblib -MDevel::Cover cover -report html_basic
self_cover : _self_cover
\t \$(PERL) -Mblib cover -report html_basic
mani : mani :
\t -rm MANIFEST \t -rm MANIFEST
\t \$(MAKE) manifest \t \$(MAKE) manifest
Expand All @@ -528,5 +542,11 @@ ok :
nok : nok :
\t \@$Perlbug -nokay || echo "Please send your report manually to $Author" \t \@$Perlbug -nokay || echo "Please send your report manually to $Author"
] ] . "\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 $_ > /dev/null 2>&1\n",
sort keys %tests;
} }

0 comments on commit 3c3aa91

Please sign in to comment.