GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Module::Used(3) User Contributed Perl Documentation Test::Module::Used(3)

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

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

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.

Some behavier changed since 0.1.3_01.
  • perl_version set in constructor is prior to use, and read version from META.yml(not read from use statement in *.pm)
  • deprecated interfaces are deleted. (module_dir, test_module_dir, exclude_in_moduledir and push_exclude_in_moduledir)

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.
    lib_dir      => ['lib'],          # directory(ies) which contains module libs.
    test_lib_dir => ['t'],            # directory(ies) which contains libs used ONLY in test (ex. MockObject for test)
    meta_file    => 'META.json' or
                    'META.yml' or
                    'META.yaml',      # META file (YAML or JSON which 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_libdir   => [],        # ignored module(s) for your 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 perl_version is not passed in constructor, this modules reads meta_file and get perl version.

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

check used modules are required in META file and required modules in META files are used.

  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.

It is NOT allowed to call ok(), used_ok() and requires_ok() in same test file.

Only check used modules are required in META file. Test will success if unused requires or build_requires are defined.

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

It is NOT allowed to call ok(), used_ok() and requires_ok() in same test file.

Only check required modules in META file is used. Test will success if used modules are not defined in META file.

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

It is NOT allowed to call ok(), used_ok() and requires_ok() in same test file.

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_libdir but manually specify exclude modules.

For example,

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

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

Takuya Tsuchida <tsucchi@cpan.org>

Test::Dependencies has almost same feature.

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

Copyright (c) 2008-2011 Takuya Tsuchida

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

2011-01-28 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.