use vars qw($VERSION @ISA);
@ISA = qw(Module::Build::Base);
-$VERSION = '0.2801';
+$VERSION = '0.2802';
$VERSION = eval $VERSION;
# Okay, this is the brute-force method of finding out what kind of
my $ans = $self->_readline();
- if ( !defined($ans) ) { # Ctrl-D
- print "\n";
- } elsif ( !length($ans) ) { # Default
+ if ( !defined($ans) # Ctrl-D or unattended
+ or !length($ans) ) { # User hit return
print "$def\n";
$ans = $def;
}
sub compare_versions {
my $self = shift;
my ($v1, $op, $v2) = @_;
-
- # for alpha versions - this doesn't cover all cases, but should work for most:
- $v1 =~ s/_(\d+)\z/$1/;
- $v2 =~ s/_(\d+)\z/$1/;
+ $v1 = Module::Build::Version->new($v1)
+ unless UNIVERSAL::isa($v1,'Module::Build::Version');
my $eval_str = "\$v1 $op \$v2";
my $result = eval $eval_str;
foreach my $spec (@$dirs) {
my $dir = $self->localize_dir_path($spec);
next unless -e $dir;
+
FILE: foreach my $file ( @{ $self->rscan_dir( $dir ) } ) {
foreach my $regexp ( @{ $args{exclude} } ) {
next FILE if $file =~ $regexp;
Revision history for Perl extension Module::Build.
+0.2802 Fri Jul 14 22:40:34 CDT 2006
+
+ - Added reliance on version.pm, which means we should deal much
+ better with the wide range of version specifications one finds on
+ CPAN. This is made possible by recent releases of version.pm that
+ give the user a pure-perl option, so installing version.pm
+ shouldn't be too onerous for most users. [John Peacock]
+
+ - We should be accepting the default when we're in unattended mode,
+ not acting dumb and ignoring both the default and the [empty]
+ answer from the user. Fixed. [Spotted by Nik Clayton]
+
0.2801 Sun May 21 00:07:40 CDT 2006
- Module::Build::Compat's emulation of INC is incorrectly prepending
use File::Spec;
use IO::File;
+use Module::Build::Version;
my $PKG_REGEXP = qr/ # match a package declaration
$line
}; \$$var
};
- local $^W;
-
- # version.pm will change the ->VERSION method, so we mitigate the
- # potential effects here. Unfortunately local(*UNIVERSAL::VERSION)
- # will crash perl < 5.8.1. We also use * Foo::VERSION instead of
- # *Foo::VERSION so that old versions of CPAN.pm, etc. with a
- # too-permissive regex don't think we're actually declaring a
- # version.
- my $old_version = \&UNIVERSAL::VERSION;
- eval {require version};
+ local $^W;
+ # Try and get the $VERSION
my $result = eval $eval;
- * UNIVERSAL::VERSION = $old_version;
warn "Error evaling version line '$eval' in $self->{filename}: $@\n" if $@;
- # Unbless it if it's a version.pm object
- $result = $result->numify if UNIVERSAL::isa($result, 'version');
+ # Bless it into our own version class
+ $result = Module::Build::Version->new($result);
return $result;
}
use strict;
use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
-use MBTest tests => 66;
+use MBTest tests => 72;
use Cwd ();
my $cwd = Cwd::cwd;
our $VERSION = "1.23";
---
+ <<'---', # $VERSION using version.pm
+ package Simple;
+ use version; our $VERSION = version->new('1.23');
+---
+ <<'---', # $VERSION using version.pm and qv()
+ package Simple;
+ use version; our $VERSION = qv('1.230');
+---
+
);
my( $i, $n ) = ( 1, scalar( @modules ) );
local $SIG{__WARN__} = sub { $warnings .= $_ for @_ };
my $pm_info = Module::Build::ModuleInfo->new_from_file( $file );
- is( $pm_info->version, '1.23',
+ cmp_ok( $pm_info->version, '==', '1.23',
"correct module version ($i of $n)" );
is( $warnings, '', 'no warnings from parsing' );
$i++;
is( $pm_info->name, undef, 'no default package' );
is( $pm_info->version, undef, 'no version w/o default package' );
+# Module 'Simple.pm' contains an alpha version
+# constructor should report first $VERSION found
+$dist->change_file( 'lib/Simple.pm', <<'---' );
+package Simple;
+$VERSION = '1.23_01';
+$VERSION = eval $VERSION;
+---
+
+$dist->regen;
+$pm_info = Module::Build::ModuleInfo->new_from_file( $file );
+
+is( $pm_info->version, '1.23_01', 'alpha version reported');
+
+# NOTE the following test has be done this way because Test::Builder is
+# too smart for our own good and tries to see if the version object is a
+# dual-var, which breaks with alpha versions:
+# Argument "1.23_0100" isn't numeric in addition (+) at
+# /usr/lib/perl5/5.8.7/Test/Builder.pm line 505.
+
+ok( $pm_info->version > 1.23, 'alpha version greater than non');
# revert to pristine state
chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
$dist->remove;
SKIP: {
- skip( 'Windows only test', 4 ) unless $^O =~ /^MSWin/;
+ skip( 'Windows-only test', 4 ) unless $^O =~ /^MSWin/;
my $script_data = <<'---';
@echo off