Test-RequiredMinimumDependencyVersion

require a minimum version for your dependencies


License
BSD-2-Clause-FreeBSD

Documentation

NAME

Test::RequiredMinimumDependencyVersion - require a minimum version for your dependencies

VERSION

Version 0.003

SYNOPSIS

use Test::RequiredMinimumDependencyVersion;
Test::RequiredMinimumDependencyVersion->new(module => { ... })->all_files_ok;

DESCRIPTION

There are some modules where you'll always depend on a minimal version, either because of a bug or because of an API change. A good example would be Test::More where version 0.88 introduced done_testing() or version which strongly urges to set 0.77 as a minimum in your code.

This test can be used to check that, whenever you use these modules, you also declare the minimum version.

This test is an author test and should not run on end-user installations. Recommendation is to put it into your xt instead of your t directory.

USAGE

new( ARGS )

Returns a new Test::RequiredMinimumDependencyVersion instance. new takes a hash with its arguments.

Test::RequiredMinimumDependencyVersion->new(
    module => {
        'Test::More' => '0.88',
    },
);

The following arguments are supported:

module (required)

The module argument is a hash ref where the keys are the modules you want to enforce and the minimal version is its value.

file_ok( FILENAME )

This will run a test for parsing the file with Perl::PrereqScanner and another test for every module you specified if it is used in this file. It is therefore unlikely to know the exact number of tests that will run in advance. Use done_testing from Test::More if you call this test directly instead of a plan.

file_ok returns something true if all checked dependencies are at least of the required minimal version and false otherwise.

all_files_ok

Calls the all_perl_files method of Test::XTFiles to get all the files to be tested. All files will be checked by calling file_ok.

It calls done_testing or skip_all so you can't have already called plan.

all_files_ok returns something true if all files test ok and false otherwise.

Please see XT::Files for how to configure the files to be checked.

WARNING: The API was changed with 0.003. Arguments to all_files_ok are now silently discarded and the method is now configured with XT::Files.

EXAMPLES

Example 1 Default Usage

Check all files in the bin, script and lib directory.

use 5.006;
use strict;
use warnings;

use Test::RequiredMinimumDependencyVersion;

Test::RequiredMinimumDependencyVersion->new(
    module => {
        'version' => '0.77',
    },
)->all_files_ok;

Example 2 Check non-default directories or files

Use the same test file as in Example 1 and create a .xtfilesrc config file in the root directory of your distribution.

[Dirs]
module = lib
module = tools
module = corpus/hello

[Files]
module = corpus/my.pm

Example 3 Call file_ok directly

use 5.006;
use strict;
use warnings;

use Test::More 0.88;
use Test::RequiredMinimumDependencyVersion;

my $trmdv = Test::RequiredMinimumDependencyVersion->new(
    module => {
        'Test::More' => '0.88',
    },
);
$trmdv->file_ok('t/00-load.t');
$trmdv->file_ok('xt/author/pod-links.t');

done_testing();

SEE ALSO

Test::More

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/skirmess/Test-RequiredMinimumDependencyVersion/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/skirmess/Test-RequiredMinimumDependencyVersion

git clone https://github.com/skirmess/Test-RequiredMinimumDependencyVersion.git

AUTHOR

Sven Kirmess sven.kirmess@kzone.ch

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018-2019 by Sven Kirmess.

This is free software, licensed under:

The (two-clause) FreeBSD License