NAME

Test::Module::Used - Test required module is really used and vice versa bitween lib/t and META.yml

SYNOPSIS

#!/usr/bin/perl -w
use strict;
use warnings;
use Test::Module::Used;
my $used = Test::Module::Used->new();
$used->ok;

DESCRIPTION

Test dependency between module and META.yml.

This module reads META.yml and get build_requires and requires. It compares required module is really used and used module is really required.

methods

new

create new instance

all parameters are passed by hash-style, and optional.

in ordinary use.

my $used = Test::Module::Used->new();
$used->ok();

all parameters are as follows.(specified values are default, except exclude_in_testdir)

my $used = Test::Module::Used->new(
  test_dir     => ['t'],            # directory(ies) which contains test scripts.
  module_dir   => ['lib'],          # directory(ies) which contains modules.
  meta_file    => 'META.yml',       # META.yml (contains module requirement information)
  perl_version => '5.008',          # expected perl version which is used for ignore core-modules in testing
  exclude_in_testdir => [],         # ignored module(s) for test even if it is used.
  exclude_in_moduledir => [],       # ignored module(s) for your module(lib) even if it is used.
  exclude_in_build_requires => [],  # ignored module(s) even if it is written in build_requires of META.yml.
  exclude_in_requires => [],        # ignored module(s) even if it is written in requires of META.yml.
);

if your module source contains use 5.XXX statement, perl_version passed in constructor is ignored (prior to use version in module source code).

exclude_in_testdir is automatically set by default. This module reads module_dir and parse "pacakge" statement, then found "package" statements and myself(Test::Module::Used) is set. exclude_in_moduledir is also automatically set by default. This module reads module_dir and parse "package" statement, found "package" statement are set.(Test::Module::Used isnt included)

ok

check used module is ok.

my $used = Test::Module::Used->new(
  exclude_in_testdir => ['Test::Module::Used', 'My::Module'],
);
$used->ok;

First, This module reads META.yml and get build_requires and requires. Next, reads module directory (by default lib) and test directory(by default t), and compare required module is really used and used module is really required. If all these requirement information is OK, test will success.

push_exclude_in_moduledir( @exclude_module_names )

add ignored module(s) for your module(lib) even if it is used after new()'ed. this is usable if you want to use auto set feature for exclude_in_moduledir but manually specify exclude modules.

For example,

my $used = Test::Module::Used->new(); #automatically set exclude_in_moduledir
$used->push_exclude_in_moduledir( qw(Some::Module::Which::You::Want::To::Exclude) );#module(s) which you want to exclude
$used->ok(); #do test

push_exclude_in_testdir( @exclude_module_names )

add ignored module(s) for test even if it is used after new()'ed. this is usable if you want to use auto set feature for exclude_in_testdir but manually specify exclude modules.

For example,

my $used = Test::Module::Used->new(); #automatically set exclude_in_testdir
$used->push_exclude_in_testdir( qw(Some::Module::Which::You::Want::To::Exclude) );#module(s) which you want to exclude
$used->ok(); #do test

AUTHOR

Takuya Tsuchida <tsucchi@cpan.org>

SEE ALSO

Test::Dependencies has almost same feature.

REPOSITORY

http://github.com/tsucchi/Test-Module-Used

LICENSE

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