[Desmoines-pm] [Testing] How to make modules available at test time, but not install

Sean Mooney smooney at sourceallies.com
Fri Mar 7 06:26:28 PST 2014


Hello. I am getting started with Perl and have a question about modules and testing.

The project is using the ExtUtils::MakeMaker for generating the makefile, and the Test::More module for running tests. There's a bunch of common functions that need to be available in the different test files, so I pulled it out into a module called Project::TestSupport::CommonSubs.pm. The project has, what I think is a fairly standard layout.

project_root
  |-lib/
    |-ProjectName
        |- Application.pm
    |-TestSupport
        |-CommonSubs.pm
  |-t/
  |-Makefile.PL

The question is how do I keep 'make install' from installing the TestSupport::CommonSubs module, but have the module available for 'make test'? Several of the subs defined in the module should not be installed in production, as they expose information about the application that shouldn't be available, but is required for the tests.

If this was a Java app, being built with say maven, I would just put that module into the 'test' directory and the class would not be packaged into the production jar. Following this idea, one approach I tried with the perl application is to create directory on the same level as 'lib' called 'lib-test' and put TestSuppport::CommonSubs in that directory. However, I have not found a way to get MakeMaker to put lib-test on the perl path when running the tests.

Do you have any suggestions as to how I can exclude TestSupport::CommonSubs from being installed by the 'make install' target?

Thanks,

Sean Mooney.
Source Allies, Inc. 


More information about the Desmoines-pm mailing list