Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: how do you build and test your modules locally before publishing

by davido (Archbishop)
on Dec 31, 2012 at 02:27 UTC ( #1010976=note: print w/replies, xml ) Need Help??

in reply to how do you build and test your modules locally before publishing

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:


...and my tests are in...


Then I could 'cd' into MyMod-Foo, and execute the following:

prove -Ilib

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:

perl Makefile.PL make prove -b

...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/

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


Replies are listed 'Best First'.
Re^2: how do you build and test your modules locally before publishing
by tobyink (Abbot) on Dec 31, 2012 at 11:40 UTC

    Huh? On my system at least, the perl option for setting a library path is an upper-case "i":

    perl -Ilib t/00-load.t

    That is, the same as prove. The lower-case "L" option (perl -l) is line end processing for one-liners.

    prove -l (lower-case "L") is a useful shortcut for prove -Ilib.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Corrected. ...sometimes things that are "force of habit" become difficult to explain. And somehow in so-doing, I managed to confuse myself. :) Thanks for the nudge.


Re^2: how do you build and test your modules locally before publishing
by gideondsouza (Pilgrim) on Dec 31, 2012 at 03:57 UTC

    Thanks very much for your reply davido. Exactly what I was looking for

    One more little query, the perldoc command doesn't seem to have a -I switch. How should I test if the POD I've written looks ok? How is it usually done?

      Test::Pod, and Test::Pod::Coverage, if memory serves. Also, Perl::Critic: One of the elevated levels of whining will grouse at you if your POD is missing sections common to modules. I think Test::Kwalitee does some POD diving too, but half the time I can't even get it to install all of its deps. Test::Kwalitee and Test::PerlCritic should always be "author-only" tests, by the way.


      perldoc allows you to provide a file path rather than a module name...

      perldoc File::Spec perldoc lib/Foo/

      I tend to view my pod in an 80x24 terminal to check there's no ugly line wrapping issues at that size.

      I also check with Test::Pod and Test::Pod::Coverage.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010976]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2018-06-25 18:46 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (128 votes). Check out past polls.