Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-Cover CPAN distribution.

Report information
The Basics
Id: 34263
Status: resolved
Priority: 0/
Queue: Devel-Cover

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

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



Subject: Fix -test for Module::Build
This is as much a reminder for myself to give you a patch as anything else. It's sort of moot as Module::Build has a testcover target but I want the -gcov stuff and it would be nice if it all Just Worked.
On Wed Mar 19 17:56:05 2008, MSCHWERN wrote: Show quoted text
> This is as much a reminder for myself to give you a patch as anything > else. It's sort of moot as Module::Build has a testcover target but I > want the -gcov stuff and it would be nice if it all Just Worked.
And here's the patch.
---------------------------------------------------------------------- r56017: schwern | 2008-03-22 19:48:58 -0700 Make cover work with Module::Build ---------------------------------------------------------------------- --- local/Devel-Cover/cover (revision 56016) +++ local/Devel-Cover/cover (revision 56017) @@ -95,6 +95,43 @@ } } +# Decide whether to run ./Build test or make test +sub test_command { + return -e 'Build.PL' ? + mb_test_command() : mm_test_command(); +} + +# Compiler arguments necessary to do a coverage run +sub gcov_args { + return "-fprofile-arcs\\ -ftest-coverage"; +} + +# Test command for MakeMaker +sub mm_test_command { + my $test = "make test"; + + if ($Options->{gcov}) + { + my $o = gcov_args(); + $test .= " OPTIMIZE=-O0\\ $o OTHERLDFLAGS=$o"; + } + + return $test; +} + +# Test command for Module::Build +sub mb_test_command { + my $test = './Build test'; + + if ($Options->{gcov}) + { + my $o = gcov_args(); + $test .= " --extra_compiler_flags=-O0\\ $o --extra_linker_flags=$o"; + } + + return $test; +} + sub main { if ($INC{"Devel/Cover.pm"}) @@ -169,14 +206,15 @@ delete_db($dbname, @ARGV); local $ENV{ -d "t" ? "HARNESS_PERL_SWITCHES" : "PERL5OPT" } = "-MDevel::Cover"; - my $test = "make test"; + + my $test = test_command(); + + # touch the XS files so they rebuild if ($Options->{gcov}) { my $t = $] > 5.7 ? undef : time; my $xs = sub { utime $t, $t, $_ if /\.xs$/ }; File::Find::find({ wanted => $xs, no_chdir => 0 }, "."); - my $o = "-fprofile-arcs\\ -ftest-coverage"; - $test .= " CCFLAGS=-O0\\ $o OTHERLDFLAGS=$o"; } print STDERR "cover: running $test\n"; system $test;
I applied this patch ages ago, so I should probably close the ticket. Thanks,