Geoffrey Young wrote:
hi all

I've managed to figure out at least preliminary support for using Test::More
as the backend for Apache::Test.  attached is a patch as well as a tarball
that uses a few Test::More features in it.  I may have missed a few of the
finer features of Test::More, but it seems to do what I need it to, namely
allowing the use of Test::More from server-side (t/response/TestFoo/foo.pm)
tests as well as allowing the existing mod_perl-2.0 test suite to run unaltered.

feedback welcome.

looks nice.

Here is the feedback:


I'd replace $plan with *plan:

+        eval {
+
+            require Test::More;
...
+
+            *plan = \&Test::More::plan;
+        } or die "-withtestmore error: $@";
+
...
+    else {
+        # the default - Test.pm support
+
+        require Test;
+        Test->import(qw(ok skip));
+        *plan = \&Test::plan;
+    }
+
...
+ plan(@_, @testmore);

or even better, since you can import plan() anyway, just use a forward declaration:

use subs qw(plan);

and then you don't need any new vars or mess with aliases. it'll be just there. which will make your code much simpler:

  eval { require Test::More } or die "-withtestmore error: $@";
  Test::More->import(@testmore);
...
else
  require Test;
  Test->import(@testmore);

which can be shrinked even further and have things much simpler: just figure which class you are going to use, load it and then import:

$class->import(@testmore);

since you die anyway with eval above.

---------

and one more nit -- The import() function may be called more than once, and every time it'll try to reimport all these symbols. So you probably want to have a flag so that you import them only once.

Also what happens if -withtestmore is not the first argument to import()?

--------

Regarding this comment:

+C<-withtestmore> tells I<Apache::Test> to use the I<Test::More> framework
+instead of the I<Test.pm> framework behind the scenes.  Note that you are
+not required to C<use Test::More> yourself with the C<-withtestmore> option.

What happens if I want to use functions from T-M, will this work?

use Apache::Test qw(-withtestmore);
is ($foo, $bar);

I guess not. Usually you want Test::More for its functionality, not ok/plan/skip. So in 99.9% cases you will want to say:

use Apache::Test qw(-withtestmore);
use Test::More;
is ($foo, $bar);

no?


---------


+ Test::Builder->failure_output(\*STDOUT);

I think Test.pm has it set to STDERR:

Test.pm:33: $TESTERR = *STDERR{IO};

so we probably want to keep things consistent, no?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Reply via email to