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

寵の児 提交于 2019-12-07 05:02:31

问题


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?


回答1:


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

use ExtUtils::MakeMaker 6.64;

WriteMakefile(
    ...,
    TEST_REQUIRES => {
        Test::More => 0.95,
        },
    ...,
    );



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/12172364/how-to-specify-test-prerequisites-in-the-extutilsmakemaker-makefile-pl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!