NAME

Test::GreaterVersion -- Test if you incremented VERSION

SYNOPSIS

has_greater_version('My::Module');

has_greater_version_than_cpan('My::Module');

DESCRIPTION

There are two functions which are supposed to be used in your test suites to assure that you incremented your version before your install the module or upload it to CPAN.

has_greater_version checks if your module source has a greater VERSION number than the version installed in the system.

has_greater_version_than_cpan checks if your module source has a greater VERSION number than the version found on CPAN.

The version is checked by looking for the VERSION scalar in the module. The names of these two functions are always exported.

The two test functions expect your module files layed out in the standard way, i.e. tests are called in the top directory and module if found in the lib directory:

Module Path
  doc
  examples
  lib
  t

The version of My::Module is therefore expected in the file lib/My/Module.pm. There's currently no way to alter that location. (The file name is OS independent via the magic of File::Spec.)

The version information is actually parsed by ExtUtils::MakeMaker.

The version numbers are compared calling CPAN::Version::vgt(). See CPAN::Version or version for version number syntax. (Short: Both 1.00203 and v1.2.30 work.)

has_greater_version ($module)

Returns 1 if the version of your module in 'lib/' is greater than the version of the installed module, 0 otherwise.

has_greater_version_than_cpan ($module)

Returns 1 if the version of your module in 'lib/' is greater than the version on CPAN, 0 otherwise.

Due to the interface of the CPAN module there's currently no way to tell if the module is not on CPAN or if there has been an error in getting the module information from CPAN. As a result this function should only be called if you are sure that there's a version of the module on CPAN.

Depending on the configuration of your CPAN shell the first call of this function may seem to block the test. When you notice this behaviour it's likely that the CPAN shell is trying to get the latest module index which may take some time.

_get_installed_version ($module)

Gets the version of the installed module. The version information is found with the help of the CPAN module.

Returns 0 if CPAN cannot find the module or it has no VERSION. Returns the version otherwise.

We don't use CPAN::Shell::inst_version() since it doesn't remove blib before searching for the version and we want to have a diag() output in the test. And because the manpage doesn't list the function in the stable interface.

_get_version_from_lib ($module)

Gets the version of the module found in 'lib/'. Transforms the module name into a filename which points to a file found under 'lib/'.

MM-parse_version()> tries to find the version.

Returns 0 if the module could not be loaded or has no VERSION. Returns the version otherwise.

_get_version_from_cpan ($module)

Gets the module's version as found on CPAN. The version information is found with the help of the CPAN module.

Returns 0 if the module is not on CPAN or the CPAN module failed somehow. Returns the version otherwise.

NOTES

This module was inspired by brian d foy's talk 'Managing Complexity with Module::Release' at the Nordic Perl Workshop in 2006.

AUTHOR

Gregor Goldbach <glauschwuffel@nomaden.org>

SIMILAR MODULES

Test::Version tests if there is a VERSION defined.

Test::HasVersion does it, too, but has the ability to check all Perl modules in lib.

Neither of these compare versions.

Copyright (c) 2007 by Gregor Goldbach. All rights reserved.

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