Skip Menu |
 

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

Report information
The Basics
Id: 25025
Status: resolved
Priority: 0/
Queue: Test-Class

People
Owner: Nobody in particular
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.22
Fixed in: (no value)



Subject: TEST_METHOD mistakenly blocks startup/shutdown methods
Download (untitled) / with headers
text/plain 597b
My tests pass via ./Build test but fail under env TEST_METHOD=search ./Build test because my startup method is not being invoked, so my test data is not being populated. The fault seems to be line 149: return grep { /\A$ENV{TEST_METHOD}\z/ } sort keys %methods; One possible (messy) fix is: my @methods = sort keys %methods; if (@types == 1 && $types [0] eq TESTS) { @methods = grep { /\A$ENV{TEST_METHOD}\z/ } @methods; } return @methods; Another approach might be to local $ENV{TEST_METHOD} = undef; before collecting the startup/shutdown methods, or something like that.
Download (untitled) / with headers
text/plain 108b
Attached is a very simple patch that works for me, but causes t/test_method.t to fail with unexpected tests.
Download test_method.patch
text/x-diff 439b
--- lib/Test/Class.pm~ 2006-11-29 14:58:49.000000000 -0600 +++ lib/Test/Class.pm 2007-02-18 16:45:18.000000000 -0600 @@ -141,7 +141,7 @@ }; }; }; - if (exists $ENV{TEST_METHOD}) { + if (exists $ENV{TEST_METHOD} && @types == 1 && $types[0] eq TEST) { eval { '' =~ /\A$ENV{TEST_METHOD}\z/ }; if (my $error = $@) { die "TEST_METHOD ($ENV{TEST_METHOD}) is not a valid regular expression: $error";
Download (untitled) / with headers
text/plain 854b
Hi Chris, Only just noticed this since fardling RT seems to have decided to stop sending e-mails... grrr.. Shall look at and sort sometime in the nearish future. Adrian On Sun Feb 18 17:43:37 2007, CDOLAN wrote: Show quoted text
> My tests pass via > ./Build test > but fail under > env TEST_METHOD=search ./Build test > because my startup method is not being invoked, so my test data is not > being populated. > > The fault seems to be line 149: > return grep { /\A$ENV{TEST_METHOD}\z/ } sort keys %methods; > One possible (messy) fix is: > my @methods = sort keys %methods; > if (@types == 1 && $types [0] eq TESTS) { > @methods = grep { /\A$ENV{TEST_METHOD}\z/ } @methods; > } > return @methods; > > Another approach might be to > local $ENV{TEST_METHOD} = undef; > before collecting the startup/shutdown methods, or something like that.
Fixed in 0.24 - on its way to CPAN now.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.