|P is for Practical|
Re: how do you build and test your modules locally before publishingby davido (Archbishop)
|on Dec 31, 2012 at 02:27 UTC||Need Help??|
prove has the "-b" and "-I" switches, which can be used to specify where to find the library(s) that the tests need to use. For example, if MyMod::Foo hasn't been built yet, and just exists in a distribution tree such as:MyMod-Foo/lib/MyMod/Foo.pm
...and my tests are in...MyMod-Foo/t/*.t
Then I could 'cd' into MyMod-Foo, and execute the following:
This assumes the module doesn't require any special build process (for example, no XS, no Makefile.PL trickery). Or if my module has a Makefile.PM that conforms to the normal module building standards:
...which first builds the module into a "blib" (build lib) directory, and then tells 'prove' to look in the MyModule-Foo/blib/ directory for the temporary built version of the module.
Perl also has the -I switch (that's -I as in Include -- <<corrected-thanks tobyink>> -- documented in perlrun. So once again, I could 'cd' into MyModule-Foo/ and type: perl -Ilib t/00-load.t, again assuming that the development version of the module resides in MyModule-Foo/lib/MyModule/Foo.pm.
If the module is standards conforming, you can use a version of the mantra: perl Makefile.PL, make, and make test, or perl Build.PL, Build, and Build test. Many authors also use environment variables to control what tests run. Additional information on distribution maintenance commands can be found in ExtUtils::MakeMaker