Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Normalize empty string versions to zero (RT#65909)

  • Loading branch information...
commit 5ec1008521ee3b1db76d83dbdafdcd649a846a7e 1 parent aed5345
David Golden dagolden authored
5 Changes
View
@@ -2,6 +2,11 @@ Revision history for Perl extension Module::Build.
0.37_06 -
+ [BUG FIXES]
+
+ - prerequisites with the empty string instead of a version are
+ normalized to "0". (RT#65909)
+
0.37_05 - Sat Feb 19 20:43:23 EST 2011
[BUG FIXES]
1  MANIFEST
View
@@ -83,6 +83,7 @@ t/properties/license.t
t/properties/module_name.t
t/properties/needs_compiler.t
t/properties/release_status.t
+t/properties/requires.t
t/properties/share_dir.t
t/README.pod
t/resume.t
5 lib/Module/Build/Base.pm
View
@@ -1931,7 +1931,8 @@ sub create_mymeta {
}
$mymeta->{dynamic_config} = 0;
$mymeta->{generated_by} = "Module::Build version $Module::Build::VERSION";
- $meta_obj = CPAN::Meta->new( $mymeta );
+ eval { $meta_obj = CPAN::Meta->new( $mymeta ) }
+ or do { use Data::Dumper; print Dumper($mymeta) };
}
# or generate from scratch, ignoring errors if META doesn't exist
else {
@@ -4593,7 +4594,7 @@ sub write_metafile {
sub normalize_version {
my ($self, $version) = @_;
- $version = 0 unless defined $version;
+ $version = 0 unless defined $version and length $version;
if ( $version =~ /[=<>!,]/ ) { # logic, not just version
# take as is without modification
54 t/properties/requires.t
View
@@ -0,0 +1,54 @@
+# sample.t -- a sample test file for Module::Build
+
+use strict;
+use lib 't/lib';
+use MBTest;
+use DistGen;
+
+plan tests => 4;
+
+# Ensure any Module::Build modules are loaded from correct directory
+blib_load('Module::Build');
+
+my ($dist, $mb, $prereqs);
+
+#--------------------------------------------------------------------------#
+# try undefined prereq version
+#--------------------------------------------------------------------------#
+
+$dist = DistGen->new( name => 'Simple::Requires' );
+
+$dist->change_build_pl(
+ module_name => 'Simple::Requires',
+ requires => {
+ 'File::Basename' => undef,
+ },
+)->regen;
+
+$dist->chdir_in;
+
+$mb = $dist->new_from_context();
+isa_ok( $mb, "Module::Build" );
+
+$prereqs = $mb->_normalize_prereqs;
+is($prereqs->{requires}{'File::Basename'}, 0, "undef prereq converted to 0");
+
+#--------------------------------------------------------------------------#
+# try empty string prereq version
+#--------------------------------------------------------------------------#
+
+$dist->change_build_pl(
+ module_name => 'Simple::Requires',
+ requires => {
+ 'File::Basename' => '',
+ },
+)->regen;
+
+$mb = $dist->new_from_context();
+isa_ok( $mb, "Module::Build" );
+
+$prereqs = $mb->_normalize_prereqs;
+is($prereqs->{requires}{'File::Basename'}, 0, "empty string prereq converted to 0");
+
+
+# vim:ts=2:sw=2:et:sta:sts=2
Please sign in to comment.
Something went wrong with that request. Please try again.