The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::Dependencies - Test that dependencies are properly listed for your dist

SYNOPSIS

Check that your module lists all external depdencies, including those that are part of the Perl core:

  use Test::Dependencies;
  all_dependencies_ok();

Ignore dependencies that are listed as core for version 5.8.8 and above:

  all_dependencies_ok(corelist => '5.8.8');

Ignore specific dependencies:

  all_dependencies_ok(ignore => [qw(Foo Bar::Baz)]);

Force tests to be run (since it only expects to be run as an author test by default):

  all_dependencies_ok(force => 1);

DESCRIPTION

This module provides an author test (by default it will only run if author testing was explicitly requested) to CPAN distributions that will check that all modules used (detected by Perl::PrereqScanner) in tests, utilities, and packages are listed in the distribution's dependencies.

It does this by scanning the distribution directory tree and comparing the requested modules to the generated MYMETA.* that were created at build time for the distribution being tested.

Note that this does NOT detect minimum version requirements.

Methods

all_dependencies_ok

  all_dependencies_ok(%options);

Basic usage is (in some .t on its own):

  use Test::Dependencies;
  all_dependencies_ok();

This will check that any module being loaded only by files in the distribution are listed in MYMETA.*, including those that are part of the Perl core. (It's good form to list core modules as dependencies as its possible they may be evicted in the future.)

The following options may be used to control the behavior:

* force
  all_dependencies_ok(force => 1);

Set this to true to force the tests to run, even if author testing isn't requested. This is almost certainly a bad idea since it's up to the author to ensure dependencies are listed properly before putting a dist on CPAN.

* ignore
  all_dependencies_ok(ignore => [qw(Some::Module Some::Other::Module)]);

Explicilty ignore failures of certain modules. This is also almost certainly a bad idea, but who am I to judge?

* corelist
  all_dependencies_ok(corelist => '5.8.8');

This will cause all modules that are listed as being a part of the Perl core from 5.8.8 and up. Note that this doesn't presently check whether or not its SINCE been deprecated, which is almost certainly a bug. TODO: Fix bug.

The versions can be anything that "is_lax" in version accepts.

AUTHOR

Matthew Horsfall (alh) - <WolfSage@gmail.com>