Er, I should probably make it clear that Test::Builder relies on a
singleton internally, but it's not really the cause of this bug.

Subtests
cause the Test::Builder->new singleton to temporarily return a
"child" version of TB.  It's trying to reuse the TB variable in
Test::XML (and other testing modules) which causes this issue.
 
Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6



----- Original Message ----
> From: Ovid <publiustemp-perl...@yahoo.com>
> To: perl-qa@perl.org
> Sent: Monday, 29 June, 2009 10:19:19
> Subject: Subtest fail with singletons
> 
> 
> The following subtest code fails badly:
> 
>     use Test::More tests => 2;
>     use Test::XML;
> 
>     ok 1;
>     subtest 'FAIL!' => sub {
>         plan tests => 1;
>         is_xml '', '', 'Singleton fail';
>     };
>     __END__
>     xml.t .. 
>     1..2
>     ok 1
>         1..1
>     Cannot run test (Singleton fail) with active children at 
> /home/ovid/pips_dev/work/Pips3/branches/rights_modeling/deps/lib/perl5/Test/XML.pm
>  
> line 57.
>         # Child (FAIL!) exited without calling finalize()
> 
> The reason this happens is because Test::XML, at the top of its code, has 
> this:
> 
> 
>     my $Test = Test::Builder->new;
> 
> If every test function simply had that line in the function, rather than 
> trying 
> to share this across all test functions, the code would work fine.
> 
> Not sure of the best way of handling this, but it's annoying as heck :(
> 
> Cheers,
> Ovid
> --
> Buy the book         - http://www.oreilly.com/catalog/perlhks/
> Tech blog            - http://use.perl.org/~Ovid/journal/
> Twitter              - http://twitter.com/OvidPerl
> Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to