开发者

Do I have to run make/make install to test each change to a Perl distribution file?

Do I have to run make and make install each time I开发者_JS百科 change a .pm file for Perl? I'm doing a ton of testing and this is becoming cumbersome.


You don't have to install the module to test it.

If I'm testing inside my distribution directory, I just use the test target:

 % make test

Or, if I'm using Module::Build:

 % ./Build test

Since make is a dependency management tool, it also takes care of any other steps it needs to perform so it can run the test target. You don't need to run each target separately. Module::Build does the same thing.

If I want to test a single file, I combine the make command with a call to perl that also uses the blib module to set the right @INC:

 % make; perl -Mblib t/single_test.t

Some people like using prove for the same thing. No matter which method I use, I'm probably using the arrow keys to move back to a previous command line to re-run it. I do very little typing in any of this.


It depends on module setup, but under the standard MakeMaker I use, "make test" runs a "make" if any files have been modified, so when doing intra-module development "make test" is the only command you need until you've finished.


Evan Carroll got it basically right. To expand on his answer: use the testing tools that come with Perl to tighten the workflow.

Let's say you are in your project directory and you hack on the files in its lib/ subdirectory. Execute prove -l to run all tests. That's easier than messing with absolute paths in the PERL5LIB environment variable.


Presumably you're editing a lib module in a non-lib location, rather than clobbering a global library for each modification - do the sensible thing and change the library path perl uses with PERL5LIB, which will append internally to @INC (the use search path):

PERL5LIB=/home/user/code/perl/project/lib perl myapp.pl

If your program isn't pure-perl and requires a make system, there is no way to do this short of rebuilding, but pure-perl (PP) doesn't really require make under normal circumstances. If you do it this way, running perl under a normal environment will yield the predictable and tested results, running it with your PERL5LIB will allow you to test the program.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜