Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow -nocp option to pod coverage.

 Add pod_nocp test.
 Fix up pod coverage testing.
  • Loading branch information...
commit 7d0ba629f7fa2ad6da68eae52e275b399cbcd261 1 parent 69412de
@pjcj authored
View
2  MANIFEST
@@ -98,6 +98,7 @@ test_output/cover/module_relative.5.008001
test_output/cover/overloaded.5.006001
test_output/cover/overloaded.5.008
test_output/cover/pod.5.006001
+test_output/cover/pod_nocp.5.006001
test_output/cover/require.5.006001
test_output/cover/require.5.008
test_output/cover/skip.5.006001
@@ -152,6 +153,7 @@ tests/Module_import.pm
tests/module_relative
tests/overloaded
tests/pod
+tests/pod_nocp
tests/PodMod.pm
tests/random/dir/file
tests/require
View
5 lib/Devel/Cover.pm
@@ -1053,7 +1053,7 @@ sub get_cover
my $p;
for (@{$Coverage_options{pod}})
{
- if (/^package|private|also_private|trust_me|pod_from$/)
+ if (/^package|private|also_private|trust_me|pod_from|nocp$/)
{
$opts{$p = $_} = [];
}
@@ -1068,7 +1068,8 @@ sub get_cover
$_ = qr/$_/ for @{$opts{$p}};
}
}
- # use Data::Dumper; print Dumper \%opts;
+ $Pod = "Pod::Coverage" if delete $opts{nocp};
+ # use Data::Dumper; print "$Pod, ", Dumper \%opts;
if ($Pod{$file} ||= $Pod->new(package => $pkg, %opts))
{
my $covered;
View
2  lib/Devel/Cover/Test.pm
@@ -60,7 +60,6 @@ sub get_params
while (<T>)
{
$self->{$1} = $2 if /__COVER__\s+(\w+)\s+(.*)/;
- $self->{$1} =~ s/-.*// if $1;
}
close T or die "Cannot close $test: $!";
}
@@ -69,6 +68,7 @@ sub get_params
$self->{test_parameters} = "$self->{select}"
. " -ignore blib Devel/Cover $self->{ignore}"
. " -merge 0 -coverage $self->{criteria}";
+ $self->{criteria} =~ s/-\w+//g;
$self->{cover_parameters} = join(" ", map "-coverage $_",
split " ", $self->{criteria})
. " -report text";
View
6 test_output/cover/pod.5.006001
@@ -4,10 +4,10 @@ Reading database from /home/pjcj/g/perl/Devel-Cover/cover_db
--------------------------------------------------------------- ------ ------
File pod total
--------------------------------------------------------------- ------ ------
-tests/Module1.pm 33.3 33.3
+tests/Module1.pm 50.0 50.0
tests/PodMod.pm 66.7 66.7
tests/pod n/a n/a
-Total 50.0 50.0
+Total 60.0 60.0
--------------------------------------------------------------- ------ ------
@@ -41,7 +41,7 @@ line err pod code
19
20 sub xx
21 {
-22 *** 0 $y++;
+22 $y++;
23 die;
24 }
25
View
128 test_output/cover/pod_nocp.5.006001
@@ -0,0 +1,128 @@
+Reading database from /home/pjcj/g/perl/Devel-Cover/cover_db
+
+
+--------------------------------------------------------------- ------ ------
+File pod total
+--------------------------------------------------------------- ------ ------
+tests/Module1.pm 50.0 50.0
+tests/PodMod.pm 33.3 33.3
+tests/pod_nocp n/a n/a
+Total 40.0 40.0
+--------------------------------------------------------------- ------ ------
+
+
+Run: ...
+Perl version: ...
+OS: ...
+Start: ...
+Finish: ...
+
+tests/Module1.pm
+
+line err pod code
+1 # Copyright 2002-2005, Paul Johnson (pjcj@cpan.org)
+2
+3 # This software is free. It is licensed under the same terms as Perl itself.
+4
+5 # The latest version of this software should be available from my homepage:
+6 # http://www.pjcj.net
+7
+8 package Module1;
+9
+10 my $y = 7;
+11 $y++;
+12
+13 sub _aa
+14 {
+15 $y++;
+16 die;
+17 die;
+18 }
+19
+20 sub xx
+21 {
+22 $y++;
+23 die;
+24 }
+25
+26 sub yy
+27 {
+28 1 $y++;
+29 }
+30
+31 sub zz
+32 {
+33 *** 0 my $x = shift;
+34 $x++;
+35 }
+36
+37 1
+38
+39 __END__
+
+
+tests/PodMod.pm
+
+line err pod code
+1 # Copyright 2005, Paul Johnson (pjcj@cpan.org)
+2
+3 # This software is free. It is licensed under the same terms as Perl itself.
+4
+5 # The latest version of this software should be available from my homepage:
+6 # http://www.pjcj.net
+7
+8 package PodMod;
+9
+10 use base "Module1";
+11
+12 1 sub vv { die }
+13 *** 0 sub ww { die }
+14 *** 0 sub yy { die }
+15
+16 1
+17
+18 __END__
+
+
+tests/pod_nocp
+
+line err pod code
+1 #!/usr/bin/perl
+2
+3 # Copyright 2002-2005, Paul Johnson (pjcj@cpan.org)
+4
+5 # This software is free. It is licensed under the same terms as Perl itself.
+6
+7 # The latest version of this software should be available from my homepage:
+8 # http://www.pjcj.net
+9
+10 # __COVER__ criteria pod-nocp-also_private-xx
+11
+12 use strict;
+13 use warnings;
+14
+15 use lib "tests";
+16
+17 use PodMod;
+18
+19 my @x;
+20
+21 sub xx
+22 {
+23 $x[shift]++;
+24 Module1::zz(0);
+25 }
+26
+27 for (0 .. 10)
+28 {
+29 if (time)
+30 {
+31 xx(0);
+32 }
+33 else
+34 {
+35 $x[1]++;
+36 }
+37 }
+
+
View
24 tests/PodMod.pm
@@ -0,0 +1,24 @@
+# Copyright 2005, 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
+
+package PodMod;
+
+use base "Module1";
+
+sub vv { die }
+sub ww { die }
+sub yy { die }
+
+1
+
+__END__
+
+=head2 vv
+
+vv
+
+=cut
View
37 tests/pod_nocp
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+# Copyright 2002-2005, 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
+
+# __COVER__ criteria pod-nocp-also_private-xx
+
+use strict;
+use warnings;
+
+use lib "tests";
+
+use PodMod;
+
+my @x;
+
+sub xx
+{
+ $x[shift]++;
+ Module1::zz(0);
+}
+
+for (0 .. 10)
+{
+ if (time)
+ {
+ xx(0);
+ }
+ else
+ {
+ $x[1]++;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.