Skip Menu |

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 17573
Status: resolved
Priority: 0/
Queue: Module-Build

People
Owner: Nobody in particular
Requestors: matt.lawrence [...] virgin.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.2611
Fixed in: (no value)



Subject: version.pm support broken
I notice that when I make my module depend on a specific version of a third-party module that uses version.pm, version-number comparison breaks. I've added a patch to tests to illustrate the problem and a code patch that solves it. (Removing the stringification of version.pm objects) I ran the new tests with and without version.pm installed, and it seemed to behave sanely. This was using Module::Build 0.2611, version 0.53 and perl 5.8.6 on linux
Subject: code.patch
Index: lib/Module/Build/Base.pm =================================================================== --- lib/Module/Build/Base.pm (revision 11772) +++ lib/Module/Build/Base.pm (working copy) @@ -646,9 +646,6 @@ *UNIVERSAL::VERSION = $old_version; warn "Error evaling version line '$eval' in $file: $@\n" if $@; - # Unbless it if it's a version.pm object - $result = "$result" if UNIVERSAL::isa( $result, 'version' ); - return $result; }
Subject: test.patch
Index: t/versions.t =================================================================== --- t/versions.t (revision 11772) +++ t/versions.t (working copy) @@ -2,12 +2,29 @@ use strict; use Test; -BEGIN { plan tests => 2 } +BEGIN { plan tests => 4 } use Module::Build; use File::Spec; -my $file = File::Spec->catfile('t', 'Sample', 'lib', 'Sample.pm'); +my $dir = File::Spec->catdir(qw( t Sample lib )); +my $file = File::Spec->catfile($dir, 'Sample.pm'); ok( Module::Build->version_from_file( $file ), '0.01', 'version_from_file' ); +ok( Module::Build->compare_versions( '1.01_01', '>', '1.01' ), 1, 'compare: 1.0_01 > 1.0' ); -ok( Module::Build->compare_versions( '1.01_01', '>', '1.01' ), 1, 'compare: 1.0_01 > 1.0' ); +# optional version.pm tests: +my $got_version = eval { require version }; +my ($v, $comp, $skip); +if ($got_version) { + $skip = 0; + $file = File::Spec->catfile($dir, 'Another.pm'); + $v = Module::Build->version_from_file( $file ); + $comp = Module::Build->compare_versions($v, '>=', '1.0') +} +else { + $skip = "version.pm not installed"; + $v = ''; +} +skip($skip, $v, 'v1.2.3', 'version_from_file using version.pm'); +skip($skip, $comp, 1, "compare: '$v' >= '1.0'" ); +
Previous test.patch was incomplete...
Index: t/Sample/lib/Another.pm =================================================================== --- t/Sample/lib/Another.pm (revision 0) +++ t/Sample/lib/Another.pm (revision 0) @@ -0,0 +1,31 @@ + +=head1 NAME + +Another - Sample file using version.pm + +=head1 AUTHOR + +Sample Man <sample@example.com> + +=head1 OTHER + +version lines in pod should be ignored: +$VERSION = 'not ok: got version from pod!'; + +=cut + +package Another; + +# version lines in comments should be ignored: +# $VERSION = 'not ok: got version from comment!'; + +# this is the version line we're looking for: +use version; our $VERSION = qv('1.2.3'); # should be eval'd + +{ + # we should only take the first version line found: + local + $VERSION = 'not ok: got second version from code!'; +} + +1; Index: t/versions.t =================================================================== --- t/versions.t (revision 11772) +++ t/versions.t (working copy) @@ -2,12 +2,29 @@ use strict; use Test; -BEGIN { plan tests => 2 } +BEGIN { plan tests => 4 } use Module::Build; use File::Spec; -my $file = File::Spec->catfile('t', 'Sample', 'lib', 'Sample.pm'); +my $dir = File::Spec->catdir(qw( t Sample lib )); +my $file = File::Spec->catfile($dir, 'Sample.pm'); ok( Module::Build->version_from_file( $file ), '0.01', 'version_from_file' ); +ok( Module::Build->compare_versions( '1.01_01', '>', '1.01' ), 1, 'compare: 1.0_01 > 1.0' ); -ok( Module::Build->compare_versions( '1.01_01', '>', '1.01' ), 1, 'compare: 1.0_01 > 1.0' ); +# optional version.pm tests: +my $got_version = eval { require version }; +my ($v, $comp, $skip); +if ($got_version) { + $skip = 0; + $file = File::Spec->catfile($dir, 'Another.pm'); + $v = Module::Build->version_from_file( $file ); + $comp = Module::Build->compare_versions($v, '>=', '1.0') +} +else { + $skip = "version.pm not installed"; + $v = ''; +} +skip($skip, $v, 'v1.2.3', 'version_from_file using version.pm'); +skip($skip, $comp, 1, "compare: '$v' >= '1.0'" ); +
Hi Matt, We now rely directly on version.pm for version checks, etc., so our support should be much improved. -Ken