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'" );
+