You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@perl.apache.org by "Christopher H. Laco" <cl...@chrislaco.com> on 2005/09/26 04:30:46 UTC

make test problem underA-T

I have a fun problem with Apache-Test and the EU::MM test=>TESTS option. 
Long story longer.

I recently added t/*.t tests to test my Catalyst helper modules. These 
tests call the helpers modules, which in turn cause Catalyst to create 
files (modules, tests, templates) in t/TestApp. Some of these 
autogenerated files are actually other test files that would be run in 
the Catalyst app itself..files like t/TestApp/t/01app.t.

When I run make test for the first time, everything runs just fine. When 
I run make test for the second time, it's trying to run 
t/TestApp/t/01app.t and other files in the bogus t directory.

> server localhost:8529 started
> t\TestApp\t\01app......................
> #     Failed test (t\TestApp\t\01app.t at line 2)
> #     Tried to use 'Catalyst::Test'.
> #     Error:  Couldn't load "TestApp", "Can't locate TestApp.pm in @INC (@INC contains: C:\Development\CPAN\Handel\blib\lib C:\Development\C
> PAN\Handel\blib\arch C:\Development\CPAN\Handel lib blib\arch blib\lib C:/Development/Perl/584/lib C:/Development/Perl/584/site/lib . C:/Dev
> elopment/Perl/584/lib C:/Development/Perl/584/site/lib .) at C:/Development/Perl/584/site/lib/Catalyst/Test.pm line 81.
> # " at (eval 3) line 2


Now, at first I thought this was really bogus. Last time I checked, 
EU::MM only runs test in t/*.t, and no tests in subdirectories. So, just 
for giggles, I added this to my Makefile.PL:

> test  => { TESTS => join ' ', (glob("t/*.t"))}

To my surprise, this didn't fix my problem. So, in Makefile.PL, I did:

> warn join "\n", (glob("t/*.t"));

This gave me:

> t/basic.t
> t/cart_add.t
> t/cart_clear.t
> t/cart_delete.t
> t/cart_item_new.t
> t/cart_items.t
> t/cart_iterator.t
> t/cart_load.t
> t/cart_new.t
> t/cart_restore.t
> t/cart_restore_append.t
> t/cart_restore_append_filter.t
> t/cart_restore_merge.t
> t/cart_restore_merge_filter.t
> t/cart_restore_replace.t
> t/cart_restore_replace_filter.t
> t/cart_save.t
> t/catalyst_helpers_controller_cart.t
> t/catalyst_helpers_controller_order.t
> t/catalyst_helpers_model_cart.t
> t/catalyst_helpers_model_order.t
> t/checkout_cart.t
> t/checkout_messages.t
> t/checkout_order.t
> t/checkout_phases.t
> t/checkout_plugins.t
> t/checkout_process.t
> t/config.t
> t/constants.t
> t/constraints_cart_type.t
> t/constraints_checkout_phase.t
> t/constraints_currency_code.t
> t/constraints_order_type.t
> t/constraints_price.t
> t/constraints_quantity.t
> t/constraints_uuid.t
> t/currency.t
> t/dbi.t
> t/exceptions.t
> t/l10n.t
> t/order_add.t
> t/order_clear.t
> t/order_delete.t
> t/order_item_new.t
> t/order_items.t
> t/order_load.t
> t/order_new.t
> t/pod_coverage.t
> t/pod_syntax.t
> t/strict.t
> t/tt2_cart.t
> t/tt2_checkout.t
> t/tt2_order.t
> t/warnings.t
> t/xsp_cart.t
> t/xsp_checkout.t
> t/xsp_order.t at Makefile.PL line 93.

So, I know the glob does what it should. I ran make test again, and it 
still is running the bogus tests in the subdirectories.

Then, I disabled Apache-Test in Makefile.PL and started over.
Now, I can run make test as many times as I want, and it never tries to 
run the tests in the subdirectories.

Just for giggles, I ran Makefile.PL twice, once with A-T enables, once 
with A-T disabled. In both cases, I left test=>TESTS glob line in 
Makefile.PL; and the t/TestApp/t direcotiry and files still exists.

Here's the noticable difference between the two: < is without A-T, > is 
with A-T:

> < TEST_VERBOSE=0
> < TEST_TYPE=test_$(LINKTYPE)
> < TEST_FILE = test.pl
> < TEST_FILES = t/basic.t t/cart_add.t t/cart_clear.t t/cart_delete.t t/cart_item_new.t t/cart_items.t t/cart_iterator.t t/cart_load.t t/cart_new.t t/cart_restore.t t/cart_restore_append.t t/cart_restore_append_filter.t t/cart_restore_merge.t t/cart_restore_merge_filter.t t/cart_restore_replace.t t/cart_restore_replace_filter.t t/cart_save.t t/catalyst_helpers_controller_cart.t t/catalyst_helpers_controller_order.t t/catalyst_helpers_model_cart.t t/catalyst_helpers_model_order.t t/checkout_cart.t t/checkout_messages.t t/checkout_order.t t/checkout_phases.t t/checkout_plugins.t t/checkout_process.t t/config.t t/constants.t t/constraints_cart_type.t t/constraints_checkout_phase.t t/constraints_currency_code.t t/constraints_order_type.t t/constraints_price.t t/constraints_quantity.t t/constraints_uuid.t t/currency.t t/dbi.t t/exceptions.t t/l10n.t t/order_add.t t/order_clear.t t/order_delete.t t/order_item_new.t t/order_items.t t/order_load.t t/order_new.t t/pod_coverage.t t/p
od_syntax.t t/strict.t t/tt2_cart.t t/tt2_checkout.t t/tt2_order.t t/warnings.t t/xsp_cart.t t/xsp_checkout.t t/xsp_order.t
> < TESTDB_SW = -d

>> TEST_VERBOSE = 0
>> TEST_FILES =
>> 


A quick gander into Apache::TestMM::test() yields this:

> TEST_VERBOSE = 0
> TEST_FILES =
> 
> test_clean :
> 	$(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) \
> 	t/TEST $(APACHE_TEST_EXTRA_ARGS) -clean
> 
> run_tests :
> 	$(PASSENV) \
> 	$(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) \
> 	t/TEST $(APACHE_TEST_EXTRA_ARGS) -bugreport -verbose=$(TEST_VERBOSE) $(TEST_FILES)


Hey, there's the empty TEST_FILES in TestMM::test. :-/
So, is this a bug, a feature, and oversite? t/TEST recurses directories 
in t which isn't as bad as the fact that it's ignoreing the option in 
Makefile.PL entirely.

In the mean time, I'm not quite sure how to overcome this second 
make-test run problem. Trying to rmtree or ulink TestApp from t withint 
the tests that creates them just gives me a boatload of access denied 
errors. Adding a test that runs last that deletes t/TestApp works, but 
that breaks t/SMOKE since we'd no depend on that test running before the 
tests that create t/TestApp.

Thughts?
-=CHris






Re: make test problem underA-T

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Christopher H. Laco wrote:
> Christopher H. Laco wrote:
> 
>> Unless there's some reason that TestMM is deliberatly ignoring the
>> test=>TESTS option, I'll patch it this evening and send that to the list.
>>
>> -=Chris
> 
> 
> Anoyher option, or something in addition to changing TestMM::test would
> be to add a norecurse option to TestRun. If an option is added to
> TestRun, can those be passed in using @ARGV and
> Apache::TestMM::filter_args();  ?

I'm ok with that.

the main reason we recurse is so you can do

  $ t/TEST t/Foo

and get all the *.t files _directly_ under t/Foo without needing to be
explicit.  this works out well for the automagical foo we do, since we might
have tests broken up by unit, such as

  t/response/TestServer

and this behavior allows us to run all the server tests with one command.
if we followed MakeMaker we'd need to add dozens of files to TEST_FILES over
in the mod_perl-land to accomplish the same.  sorry if the behavior was a
surprise, though.  however, nobody had complained yet :)

additionally, note two things here...

  - only t/Foo/*.t files are run.  if t/Foo/Bar is a directory t/Foo/Bar/*.t
 files are not run

  - prove behaves this way, so there are others that think this is a
MakeMaker fault as well :)

--Geoff

Re: make test problem underA-T

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Christopher H. Laco wrote:
> Unless there's some reason that TestMM is deliberatly ignoring the 
> test=>TESTS option, I'll patch it this evening and send that to the list.
> 
> -=Chris

Anoyher option, or something in addition to changing TestMM::test would 
be to add a norecurse option to TestRun. If an option is added to 
TestRun, can those be passed in using @ARGV and 
Apache::TestMM::filter_args();  ?

-=Chris

Re: make test problem underA-T

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Christopher H. Laco wrote:
> It's not the prettiest thing in the world, but it works... :-)
> http://handelframework.com/source/trunk/Makefile.PL

Boy did I open a can of worms.
Under my 5.6.1 install, perl segfaults with the Makefile.PL above.

As it turned out, that install has Devel::Cover 0.55/Apache::Test 1.26 
installed....it's crashing in this line in TestMM::test

> if (eval {require Dexvel::Cover}) {

Even stranger, changing that to this works:

> if (eval 'require Dexvel::Cover') {

Stranger yet:

> perl -e "eval {require Devel::Cover};" 

also works just fine. :-(

When I install Devel::Cover 0.55, its make test went without a hitch.
Lord knows what that is all about. It is on my win32 install afterall. :-0

-=Chris



Re: make test problem underA-T

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
It's not the prettiest thing in the world, but it works... :-)
http://handelframework.com/source/trunk/Makefile.PL

Re: make test problem underA-T

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Christopher H. Laco wrote:
> Geoffrey Young wrote:
> 
>> skip the tests entirely unless Apache::Test is 1.27?  something akin
>> to this
>> ought to do the trick...
>>
>>   http://search.cpan.org/src/GEOFF/Apache-Clean-0.05/Makefile.PL
>>
>> --Geoff
>>
>>
> 
> That doesn't make a lot of sense in my case. Skipping ~20 test files
> when only ~4 of those really need Apache-Test is overkill. Running the
> other ~16 is still good information to be had when A-T is not installed.

see also the all.t file

  http://search.cpan.org/src/GEOFF/Apache-SSLLookup-2.00_04/t/ssl/all.t

> 
> Aside from that, that's a good example. Thanks.

:)

> 
> Is there an ETA on 1.27?

the next mp2 version is due out soonish, so probably then.

but really, you should find a solution that takes into account some users
will be using older A-T versions for a very long time...

--Geoff

Re: make test problem underA-T

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Geoffrey Young wrote:
> skip the tests entirely unless Apache::Test is 1.27?  something akin to this
> ought to do the trick...
> 
>   http://search.cpan.org/src/GEOFF/Apache-Clean-0.05/Makefile.PL
> 
> --Geoff
> 
> 

That doesn't make a lot of sense in my case. Skipping ~20 test files 
when only ~4 of those really need Apache-Test is overkill. Running the 
other ~16 is still good information to be had when A-T is not installed.

Aside from that, that's a good example. Thanks.

Is there an ETA on 1.27?

-=Chris



Re: make test problem underA-T

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Christopher H. Laco wrote:
> Geoffrey Young wrote:
> 
>>> Hey, why wait until I get home. See attached patch: TestMM.pm.patch.
>>
>>
>>
>> thanks.  applied, tested, committed.
>>
>> --Geoff
>>
>>
> So, with that in hand, how do I deal with the present, before 1.27?

skip the tests entirely unless Apache::Test is 1.27?  something akin to this
ought to do the trick...

  http://search.cpan.org/src/GEOFF/Apache-Clean-0.05/Makefile.PL

--Geoff

Re: make test problem underA-T

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Geoffrey Young wrote:
>>Hey, why wait until I get home. See attached patch: TestMM.pm.patch.
> 
> 
> thanks.  applied, tested, committed.
> 
> --Geoff
> 
> 
So, with that in hand, how do I deal with the present, before 1.27?

I think I can just make my own Apache::TestMM::test in my Makefile.PL 
after I load TestMM, and have it include the modified code.

 From the looks of it, TestMM will can and overwrite and MY::test found 
when it loads.

I hate doing that, but it works. When the next version of A-T hits, I 
can remove the hack and bump the PREREQ.

-=Chris

Re: make test problem underA-T

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Hey, why wait until I get home. See attached patch: TestMM.pm.patch.

thanks.  applied, tested, committed.

--Geoff

Re: make test problem underA-T

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Geoffrey Young wrote:
>>Unless there's some reason that TestMM is deliberatly ignoring the
>>test=>TESTS option, 
> 
> 
> none that I can think of
> 
> 
>>I'll patch it this evening and send that to the list.
> 
> 
> excellent.
> 
> --Geoff
> 
> 
Hey, why wait until I get home. See attached patch: TestMM.pm.patch.

All this patch does is toss {test=>TESTS} from Makefile.PL into the 
generated Makefile. In order to do that with the least amount of 
tweaking to test(), I've reverse TEST_FILES and TEST_VERBOSE variables 
in the output. No biggie.

I'm not too thrilled with the code style, but test() isn't the most 
straight foward piece of code either. :-)

-=Chris

Re: make test problem underA-T

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Unless there's some reason that TestMM is deliberatly ignoring the
> test=>TESTS option, 

none that I can think of

> I'll patch it this evening and send that to the list.

excellent.

--Geoff

Re: make test problem underA-T

Posted by "Christopher H. Laco" <cl...@chrislaco.com>.
Geoffrey Young wrote:
>>Hey, there's the empty TEST_FILES in TestMM::test. :-/
>>So, is this a bug, a feature, and oversite? 
> 
> 
> hmm...
> 
> well, I use TEST_FILES all the time
> 
>   $ make test TEST_FILES=t/Foo TEST_VERBOSE=1
> 
> and it works just fine.  the crux of this very long message is that TESTS in
> Makefile.PL ought to be propagated somehow but isn't?

Correct. Easy to fix. I didn't want to patch it before I knew whether 
this was intended behaviour for some reason?

>
> 
>>t/TEST recurses directories
>>in t 
> 
> 
> it has always behaved this way, which is far more useful and better than
> MakeMaker's default behavior :)  so, don't expect that to change.

I agree, but I don't. ;-> While it may be usefull, it breaks 
expectations and makes the 'make test' behave in two completely 
different ways in terms of what is found in t.

M::B does exactly the same thing as EU::MM and just runs test.pl and 
t/*.t. The simple act of using Apache-Test for just one or two 
http=based test files in a test suite completely changes how make test 
operates with respect to what files it runs. I think that's a Bad Thing. 
It's even more frustrating if youre test suite runs with AND without 
Apache-Test.

But alas, that will probably never change just because 'its always been 
that way'.

In either case, it's probably moot if TestMM did what it should with the 
test=>TESTS option in Makefile.PL.

Unless there's some reason that TestMM is deliberatly ignoring the 
test=>TESTS option, I'll patch it this evening and send that to the list.

-=Chris

Re: make test problem underA-T

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Christopher H. Laco wrote:
> I have a fun problem with Apache-Test and the EU::MM test=>TESTS option.
> Long story longer.
> 
> I recently added t/*.t tests to test my Catalyst helper modules. These
> tests call the helpers modules, which in turn cause Catalyst to create
> files (modules, tests, templates) in t/TestApp. Some of these
> autogenerated files are actually other test files that would be run in
> the Catalyst app itself..files like t/TestApp/t/01app.t.

did you try using t_write_file()?  that's a far better approach, since the
files are automatically cleaned up afterward.  there's also
t_write_perl_script() which writes out the file with a build-specific
shebang line.

[too much to digest]

> Hey, there's the empty TEST_FILES in TestMM::test. :-/
> So, is this a bug, a feature, and oversite? 

hmm...

well, I use TEST_FILES all the time

  $ make test TEST_FILES=t/Foo TEST_VERBOSE=1

and it works just fine.  the crux of this very long message is that TESTS in
Makefile.PL ought to be propagated somehow but isn't?

> t/TEST recurses directories
> in t 

it has always behaved this way, which is far more useful and better than
MakeMaker's default behavior :)  so, don't expect that to change.

> which isn't as bad as the fact that it's ignoreing the option in
> Makefile.PL entirely.

probably.

> 
> In the mean time, I'm not quite sure how to overcome this second
> make-test run problem. Trying to rmtree or ulink TestApp from t withint
> the tests that creates them just gives me a boatload of access denied
> errors. Adding a test that runs last that deletes t/TestApp works, but
> that breaks t/SMOKE since we'd no depend on that test running before the
> tests that create t/TestApp.

well, let's work on one thing at a time...

--Geoff