NAME

lib::prereqs::only - Only allow loading modules specified in prereqs in dist.ini

VERSION

This document describes version 0.004 of lib::prereqs::only (from Perl distribution lib-prereqs-only), released on 2017-01-11.

SYNOPSIS

To test your distribution:

% cd Your-Dist
% PERL5OPT=-Mlib::prereqs::only prove -l

To allow RuntimeRecommends prereqs too:

% PERL5OPT=-Mlib::prereqs::only=RuntimeRecommends,1 prove -l

To test script:

% PERL5OPT=-Mlib::prereqs::only some-script

To test script in your distribution (as well as turn debugging on, and allowing core modules even though they are not specified in dist.ini):

% cd Your-Dist
% perl -Mlib::prereqs::only=debug,1,allow_core,1 -Ilib bin/some-script

DESCRIPTION

This pragma reads the prerequisites found in dist.ini, the modules found in lib/, and uses lib::filter to only allow those modules to be locateable/loadable. It is useful while testing Dist::Zilla-based distribution: it tests that the prerequisites you specify in dist.ini is already complete (at least to run the test suite).

Some caveats:

  • For using with prove, this pragma currently only works via PERL5OPT

    Using:

    % prove -Mlib::prereqs::only ...

    currently does not work, because the test script is run in a separate process.

By default, only prereqs specified in RuntimeRequires and TestRequires sections are allowed. But you can include other sections too if you want:

% PERL5OPT=-Mlib::prereqs::only=RuntimeRecommends,1,TestSuggests,1 prove ...

Currently only (Runtime|Test)(Requires|Recommends|Suggests) are recognized.

Other options that can be passed to the pragma:

  • allow_core => bool (default: 1)

    This will be passed to lib::filter. By default (allow_core=1), core modules will also be allowed. If you specify core modules in your prereqs and want to test that, perhaps you want to set this to 0 (but currently XS modules won't work with allow_core set to 0).

  • debug => bool (default: 0)

    If set to 1, will print debug messages.

  • allow => str

    Specify an extra set of modules to allow. Value is a semicolon-separated list of module names. Will be passed to lib::filter.

  • disallow => str

    Specify an extra set of modules to disallow. Value is a semicolon-separated list of module names. Will be passed to lib::filter.

  • allow_re => str

    Specify module pattern to allow. Will be passed to lib::filter.

  • disallow_re => str

    Specify module pattern to disallow. Will be passed to lib::filter.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/lib-prereqs-only.

SOURCE

Source repository is at https://github.com/perlancar/perl-lib-prereqs-only.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=lib-prereqs-only

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

lib::filter

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.