tilly has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to set up a simple site with Catalyst. When you create one with catalyst.pl, it creates a Makefile.PL in your root directory. Execute that and you get a Makefile, which comes with several useful targets including test, that runs the tests in the t/ directory. As you add more to the site, you can run that again and it will pick up more tests.

Does anyone know how to configure it so that it will look in more places than just t/ for test files? I'd like to be able to scatter foo.t files to locations like lib/AppName/Schema/Results/t/ and have it pick them up automatically when I next run Makefile.PL.

The obvious option is that I could edit the Makefile manually to do what I want, but if I do that then there will be a problem if Makefile.PL is run again, and Makefile.PL has a warning that if it is removed that the site won't work as expected. I don't feel like finding out directly how the framework could break.

Replies are listed 'Best First'.
Re: Configuring Catalyst's Makefile.PL?
by tilly (Archbishop) on Mar 23, 2009 at 02:36 UTC
    I hate to have to answer my own question, but I figured it out.

    The default Makefile.PL that is supplied uses inc::Module::Install which is just a thin wrapper around Module::Install. There was some promising-looking but highly misleading code in Module::Install::Makefile. When I got past that, it turns out that I seem to be getting the default behaviour from ExtUtils::MakeMaker. Which is to run everything of the form t/*.t, and to also execute a file called test.pl if one exists.

    My solution was therefore to create a file called test.pl that looks like this:

    # Run all of the tests below the lib directory. exec(qw(prove --lib lib --recurse lib));
    Ugly and hackish, but it works.
        No problems with that here.

        I tested that by editing the Makefile to have a new option that depended on test running, and found that this option properly stopped at the failing test and did not do any further actions.

        But thanks for making me concerned enough to test it.

      I love to not have to answer your question and still get the benefits though. :) Nice going.