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