Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 67862
Status: resolved
Priority: 0/
Queue: Test-TestCoverage

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

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



Subject: Test::TestCoverage makes Moose not calling to BUILD method
Found that BUILD methods are not being called in tests using Test::TestCoverage on Moose objects. Please, see the proof of concept attached files. ----------------------------------------------------------------- --- Flags: category=core severity=high --- Site configuration information for perl 5.12.3: Configured by Alex at Fri Apr 15 02:45:00 CEST 2011. Summary of my perl5 (revision 5 version 12 subversion 3) configuration: Platform: osname=linux, osvers=2.6.35-28-generic-pae, archname=i686-linux-thread-multi uname='linux ix 2.6.35-28-generic-pae #49-ubuntu smp tue mar 1 14:58:06 utc 2011 i686 gnulinux ' config_args='-de -Dprefix=/home/alexm/perl5/perlbrew/perls/perl-5.12.3 -Dusethreads -Dcf_by=Alex -Dcf_email=alexm@cpan.org' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.4.5', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /usr/lib64 libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.12.1.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.12.1' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Locally applied patches: --- @INC for perl 5.12.3: /home/alexm/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/i686-linux-thread-multi /home/alexm/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3 /home/alexm/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/i686-linux-thread-multi /home/alexm/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3 . --- Environment for perl 5.12.3: HOME=/home/alexm LANG=ca_ES.utf8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/home/alexm/perl5/perlbrew/bin:/home/alexm/perl5/perlbrew/perls/perl-5.12.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games PERLBREW_PATH=/home/alexm/perl5/perlbrew/bin:/home/alexm/perl5/perlbrew/perls/perl-5.12.3/bin PERLBREW_PERL=perl-5.12.3 PERLBREW_ROOT=/home/alexm/perl5/perlbrew PERLBREW_VERSION=0.18 PERL_BADLANG (unset) SHELL=/bin/bash
Subject: foobar-fail.t
#!perl use strict; use warnings; use Test::More; use Test::TestCoverage; my $class = 'Foobar'; test_coverage($class); test_coverage_except( $class, qw( BUILD meta ) ); use_ok($class); my $obj = new_ok( $class => [] ); is( $obj->attr, 'foobar', 'attr is foobar' ); ok_test_coverage($class); done_testing();
Subject: Foobar.pm
package Foobar; use strict; use warnings; use Moose; has 'attr' => ( is => 'rw', isa => 'Str', ); sub BUILD { my $self = shift; $self->attr( 'foobar' ); } 1;
Subject: foobar-pass.t
#!perl use strict; use warnings; use Test::More; my $class = 'Foobar'; use_ok($class); my $obj = new_ok( $class => [] ); is( $obj->attr, 'foobar', 'attr is foobar' ); done_testing();
Hi Alex, thanks for your bug report. I've just uploaded version 0.09 of the module. That should fix the problem, I really appreciate any feedback! - Renée
Hi Renée, i still have some errors in my tests and i think it's because $wrapper also calls to original sub in after method modifier. I just changed the line: $meta->add_after_method_modifier( $sub, $wrapper ); With this (which passes my tests now): $meta->add_after_method_modifier( $sub, sub { $invokes->{$package}->{$sub}++; } ); Since my original test was idempotent, the effect of calling to original sub several times was undetected. But on my tests i perform a file moving, so it can be performed successfully only 1 time. Maybe you could add a new method to TestCoverage::Foobar so that it changes attr, e.g.: sub change { my $self = shift; $self->attr( $self->attr x 2 ); } So after calling change() once, your current version will set attr to 'foobar' x 4 instead of 'foobar' x 2, which is wrong. Hope that helps, Alex
Hi Alex, thanks for the feedback. I'll fix this in a few hours. - Renée
Hi Renée, all my tests pass with 0.11. Thanks! Alex