Skip Menu |

This queue is for tickets about the Test-Harness CPAN distribution.

Report information
The Basics
Id: 25559
Status: rejected
Priority: 0/
Queue: Test-Harness

People
Owner: Nobody in particular
Requestors: perl [...] infotrope.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Devel::Cover --cover option
Subject: Patch to provide Devel::Cover-age from "prove"
This patch provides a new command line arg for "prove": prove -c prove --cover prove --cover=args This generates a Devel::Cover coverage report. Docs and tests are also included. I eagerly await a release to put me out of my D::C misery.
Subject: prove-cover.diff
Index: t/prove-switches.t =================================================================== --- t/prove-switches.t (revision 9280) +++ t/prove-switches.t (working copy) @@ -18,7 +18,7 @@ # http://rt.perl.org/rt3/Ticket/Display.html?id=30952. plan skip_all => 'Skipping because of a Cygwin bug' if ( $^O =~ /cygwin/i ); -plan tests => 11; +plan tests => 13; my $blib = File::Spec->catfile( File::Spec->curdir, 'blib' ); my $blib_lib = File::Spec->catfile( $blib, 'lib' ); @@ -121,7 +121,22 @@ ); } +PROVE_SWITCHES_DEVEL_COVER: { + output_matches( + [ qx/$prove -c -Dd/ ], + [ '# $Test::Harness::Switches: -w -MDevel::Cover' ], + 'prove -c OK' + ); +} +PROVE_SWITCHES_DEVEL_COVER_SWITCHES: { + output_matches( + [ qx/$prove --cover=foo -Dd/ ], + [ '# $Test::Harness::Switches: -w -MDevel::Cover=foo' ], + 'prove -c OK' + ); +} + sub output_matches { my $actual = shift; my $expected = shift; Index: bin/prove =================================================================== --- bin/prove (revision 9280) +++ bin/prove (working copy) @@ -16,6 +16,7 @@ my $dry = 0; my $blib = 0; my $lib = 0; +my $cover; # make this undef so we can test for definedness later my $recurse = 0; my @includes = (); my @switches = ('-w'); @@ -31,6 +32,7 @@ Getopt::Long::Configure( 'bundling' ); GetOptions( 'b|blib' => \$blib, + 'c|cover:s' => \$cover, 'd|debug' => \$Test::Harness::debug, 'D|dry' => \$dry, 'h|help|?' => sub {pod2usage({-verbose => 1}); exit}, @@ -71,6 +73,16 @@ # Build up TH switches push( @switches, map { /\s/ && !/^".*"$/ ? qq["-I$_"] : "-I$_" } @includes ); + +# Add coverage with Devel::Cover +if (defined $cover) { + if ($cover) { + push( @switches, "-MDevel::Cover=$cover"); + } else { + push( @switches, "-MDevel::Cover"); + } +} + $Test::Harness::Switches = join( ' ', @switches ); print "# \$Test::Harness::Switches: $Test::Harness::Switches\n" if $Test::Harness::debug; @@ -202,6 +214,12 @@ Adds blib/lib to the path for your tests, a la "use blib". +=head2 -c, --cover + +Create a coverage report using L<Devel::Cover>. Optionally takes +arguments (eg. C<--cover=-db,cover_db,-coverage>). See L<Devel::Cover> +for which arguments are used. + =head2 -d, --debug Include debug information about how F<prove> is being run. This
On Mon Jul 11 23:01:01 2005, IAN wrote: Show quoted text
I've just submitted a patch for this. See RT ticket #25559. Kirrily (skud@cpan.org)
Hrm, discovered something that probably needs a doc tweak. If --cover is the last arg you pass in, it eats up the first filename as the coverage args. For instance: prove --cover t/*.t Shell expansion occurs, and the list of test files is passed to prove. --cover picks up 00_compiles.t as its argument, so it's trying to do -MDevel::Cover=00_compiles.t, leading to something like: t/assert............Devel::Cover: Unknown option t/00compile.t ignored Not sure exactly the best way to fix this, other than to say "note: if --cover is your last arg, you'll need to stop it from doing this by using -- afterwards, eg: prove --cover -- t/*.t" K.
Is it acceptable to use: HARNESS_PERL_SWITCHES=-MDevel::Cover prove -rb t ? I'd rather not complicate the arg processing of prove unnecessarily.