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
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.
Attached is a very simple patch that works for me, but causes t/test_method.t to fail with unexpected tests.
--- 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";
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.