What's better? -Ilib or -Mblib?

ferreira on 2008-02-13T17:13:46

When testing/playing with a distribution, one usually runs:

$ perl Makefile.PL; make
$ perl -Mblib demo.pl
# or (with tests)
$ prove -b test.t

Sometime the make (or ./Build) gets annoying and a shortcut is nice:

$ perl -Ilib demo.pl
# or
$ prove -l test.t

However, there are a bunch of reasons not do that. Among them:

  • -Ilib won't work for modules with XS parts (it will use installed XS components or fail to load)
  • the current build settings may establish an environment different from the current lib/ layout (with modules not in the MANIFEST and things like that)

At the end, we conclude that working under -Mblib is safer (and closer to release conditions) than playing with -Ilib.


What I did...

Alias on 2008-02-14T00:04:08

For test debugging (which is what I care about the most, since I spend sometimes hours a day in the perl debugger in tests) I used to do both by putting a sensitive BEGIN block inside the test script itself.

Mostly it just annoys me there is so much typing to do it properly (-Mblib).

It was getting really annoying to have to have special code in test scripts to avoid lots of typing.

So in the end I decided I needed to make a better tool instead, and created pler, which just Does What You Mean for debugging.

It runs Makefile.PL if needed, or Build.PL if needed, or runs make if needed, it checks for and sets up blib, it makes sure the tests run from the distro root if you are trying to run the tests from inside t.

So I just run "pler 1" and it does "cd ..; Makefile.PL; make; perl -Mblib t/01_load.t" or whatever it is that is needed to run the tests "properly".