Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify test prerequisites in the ExtUtils::MakeMaker Makefile.PL

PREREQ_PM specifies the runtime prerequisites, but how to specify which modules are required to run the test cases?

Should I use BUILD_REQUIRES for this?

like image 591
Tim Avatar asked Aug 29 '12 06:08

Tim


3 Answers

As of ExtUtils::MakeMaker 6.64, there is a TEST_REQUIRES parameter.

use ExtUtils::MakeMaker 6.64;

WriteMakefile(
    ...,
    TEST_REQUIRES => {
        Test::More => 0.95,
        },
    ...,
    );
like image 56
brian d foy Avatar answered Nov 06 '22 18:11

brian d foy


The CPAN::Meta::Spec defines how modules communicate their prerequisites to the toolchain. The version 2 spec revised the way prerequisites are listed. The test phase now has its own list of prerequisites.

But MakeMaker hasn't been updated for the v2 spec, and likely never will be. The only fully-compliant v2 distribution tool I know of is Dist::Zilla (and I recommend it for more reasons than that).

When CPAN::Meta::Converter converts from the v2 spec to v1.4, it merges the test requirements into build_requires.

So yes, if you stick with MakeMaker, any modules that are required to run the tests should be listed in BUILD_REQUIRES. PREREQ_PM should contain only modules that are still required after the module is installed.

like image 20
cjm Avatar answered Nov 06 '22 17:11

cjm


If the tests fail without a module, then I list it in PREREQ_PM regardless of whether it's needed for testing or for running the module.

If I need modules for some tests, but they are not needed to run the module, I detect those when the tests are run, and I skip the tests (with a PASS) if I can't find them.

I don't think there is any field in ExtUtils::MakeMaker for what you want.

like image 1
mirod Avatar answered Nov 06 '22 17:11

mirod