How can I run only a specific test in a Perl distribution?

前端 未结 2 1578
予麋鹿
予麋鹿 2021-02-19 03:26

This question is related to this question I asked before. I have multiple test files (A.t, B.t, C.t etc) created to test their respective module A, B, C & so on. But when I

2条回答
  •  梦谈多话
    2021-02-19 03:56

    I just run the test that I want to run:

     % make; perl -Mblib t/B.t
    

    You can do the same thing with prove, too.


    That -Mblib loads the module blib which merely adds blib/lib (and various special directories under it) to @INC for you. It comes with Perl. prove should do the same thing with the -b switch.

    My command is really two parts: the make (or ./Build for Module::Build. This builds the source and moves Perl modules and other files into the "build library", or blib, as an intermediate step in the full installation. Normally make test works against the versions in blib and refreshes that for me. Since I'm testing on my own, I ensure that I refresh blib myself and include it in Perl's module search path.

    Despite the fact that I know all this, you might be surprised that I often forget to do one of those steps and end up testing against the wrong version of things, whether the fully installed old version (forgot -Mblib) or the old development sources (forgot make). This leads me to debugging statements such as:

    print "No really, this is the Foo version. kthnxbye\n";
    

提交回复
热议问题