FAQ
If you turn on TAP::Harness, the testcover action won't work because TAP::Harness doesn't use HARNESS_PERL_SWITCHES. The patch below fixes that, but it uses Storable, which wasn't in core until 5.7.3. Alternative implementation ideas?



--- Module-Build-0.36_10/lib/Module/Build/Base.pm 2010-05-19 17:39:41.000000000 -0500
+++ Module-Build-0.36_10-patch/lib/Module/Build/Base.pm 2010-05-27 07:31:26.000000000 -0500
@@ -18,6 +18,7 @@
use File::Compare ();
use Module::Build::Dumper ();
use IO::File ();
+use Storable qw< dclone >;
use Text::ParseWords ();

use Module::Build::ModuleInfo;
@@ -2697,7 +2698,26 @@
local $Test::Harness::Switches =
local $ENV{HARNESS_PERL_SWITCHES} = "-MDevel::Cover";

- $self->depends_on('test');
+ my $orig_tap_harness_args;
+ if ( my $tap_harness_args = $self->tap_harness_args() ) {
+ $tap_harness_args = dclone($tap_harness_args);
+ $orig_tap_harness_args = dclone($tap_harness_args);
+ my $switches = $tap_harness_args->{switches} || [];
+ push @{$switches}, '-MDevel::Cover';
+ $tap_harness_args->{switches} = $switches;
+ $self->tap_harness_args($tap_harness_args);
+ }
+
+ my $worked = eval {
+ $self->depends_on('test');
+ 1;
+ };
+ my $error = $@;
+ if ($orig_tap_harness_args) {
+ $self->tap_harness_args($orig_tap_harness_args);
+ }
+ die $error if not $worked;
+
$self->do_system('cover');
}

Search Discussions

  • Eric Wilhelm at May 27, 2010 at 7:37 pm
    # from Elliot Shank
    # on Thursday 27 May 2010 05:46:
    it uses Storable, which wasn't in core until 5.7.3
    +    $tap_harness_args = dclone($tap_harness_args);
    +    $orig_tap_harness_args = dclone($tap_harness_args);
    +    my $switches = $tap_harness_args->{switches} || [];
    +    push @{$switches}, '-MDevel::Cover';
    +    $tap_harness_args->{switches} = $switches;
    $orig_th_args = {%$th_args};
    $th_args->{switches} =
    [@{$th_args->{switches}||[]}, '-MDevel::Cover'];

    --Eric
    --
    "It is a mistake to allow any mechanical object to realize that you are
    in a hurry."
    --Ralph's Observation
    ---------------------------------------------------
    http://scratchcomputing.com
    ---------------------------------------------------
  • Elliot Shank at May 28, 2010 at 2:12 am

    On 5/27/10 2:37 PM, Eric Wilhelm wrote:
    # from Elliot Shank
    # on Thursday 27 May 2010 05:46:
    it uses Storable, which wasn't in core until 5.7.3
    + $tap_harness_args = dclone($tap_harness_args);
    + $orig_tap_harness_args = dclone($tap_harness_args);
    + my $switches = $tap_harness_args->{switches} || [];
    + push @{$switches}, '-MDevel::Cover';
    + $tap_harness_args->{switches} = $switches;
    $orig_th_args = {%$th_args};
    $th_args->{switches} =
    [@{$th_args->{switches}||[]}, '-MDevel::Cover'];
    Aha. Yeah, depth two copy is enough.
  • David Golden at May 28, 2010 at 3:29 pm
    If you could please send me a new patch (or a git pull request), I'll
    apply it to the repo.

    Thanks,
    David
    On Thu, May 27, 2010 at 10:11 PM, Elliot Shank wrote:
    On 5/27/10 2:37 PM, Eric Wilhelm wrote:

    # from Elliot Shank
    # on Thursday 27 May 2010 05:46:
    it uses Storable, which wasn't in core until 5.7.3
    +    $tap_harness_args = dclone($tap_harness_args);
    +    $orig_tap_harness_args = dclone($tap_harness_args);
    +    my $switches = $tap_harness_args->{switches} || [];
    +    push @{$switches}, '-MDevel::Cover';
    +    $tap_harness_args->{switches} = $switches;
    $orig_th_args = {%$th_args};
    $th_args->{switches} =
    [@{$th_args->{switches}||[]}, '-MDevel::Cover'];
    Aha.  Yeah, depth two copy is enough.
  • Elliot Shank at May 31, 2010 at 9:01 pm

    On 5/28/10 10:29 AM, David Golden wrote:
    If you could please send me a new patch (or a git pull request), I'll
    apply it to the repo.
    How's this? Inline /and/ attached. :]

    --- Module-Build-0.36_10/lib/Module/Build/Base.pm 2010-05-19 17:39:41.000000000 -0500
    +++ Module-Build-0.36_10-patch/lib/Module/Build/Base.pm 2010-05-31 15:47:44.000000000 -0500
    @@ -2697,7 +2697,22 @@
    local $Test::Harness::Switches =
    local $ENV{HARNESS_PERL_SWITCHES} = "-MDevel::Cover";

    - $self->depends_on('test');
    + my $orig_tap_harness_args = $self->tap_harness_args();
    + if ( $self->use_tap_harness() or $orig_tap_harness_args ) {
    + my %tap_harness_args = %{$orig_tap_harness_args || {}};
    + $tap_harness_args{switches} =
    + [ @{$tap_harness_args{switches} || []}, '-MDevel::Cover' ];
    + $self->tap_harness_args(\%tap_harness_args);
    + }
    +
    + my $worked = eval {
    + $self->depends_on('test');
    + 1;
    + };
    + my $error = $@;
    + $self->tap_harness_args($orig_tap_harness_args);
    + die $error if not $worked;
    +
    $self->do_system('cover');
    }

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmodule-build @
categoriesperl
postedMay 27, '10 at 12:46p
activeMay 31, '10 at 9:01p
posts5
users3
websitecpan.org...

People

Translate

site design / logo © 2018 Grokbase