[Rt-commit] r5548 - in Test-Dependencies/trunk: . inc/Module lib/Test t

zev at bestpractical.com zev at bestpractical.com
Tue Jul 11 16:24:33 EDT 2006


Author: zev
Date: Tue Jul 11 16:24:30 2006
New Revision: 5548

Modified:
   Test-Dependencies/trunk/   (props changed)
   Test-Dependencies/trunk/Changes
   Test-Dependencies/trunk/MANIFEST
   Test-Dependencies/trunk/META.yml
   Test-Dependencies/trunk/Makefile.PL
   Test-Dependencies/trunk/inc/Module/AutoInstall.pm
   Test-Dependencies/trunk/inc/Module/Install.pm
   Test-Dependencies/trunk/inc/Module/Install/AutoInstall.pm
   Test-Dependencies/trunk/inc/Module/Install/Base.pm
   Test-Dependencies/trunk/inc/Module/Install/Can.pm
   Test-Dependencies/trunk/inc/Module/Install/Fetch.pm
   Test-Dependencies/trunk/inc/Module/Install/Include.pm
   Test-Dependencies/trunk/inc/Module/Install/Makefile.pm
   Test-Dependencies/trunk/inc/Module/Install/Metadata.pm
   Test-Dependencies/trunk/inc/Module/Install/Win32.pm
   Test-Dependencies/trunk/inc/Module/Install/WriteAll.pm
   Test-Dependencies/trunk/lib/Test/Dependencies.pm
   Test-Dependencies/trunk/t/00-load-basic.t
   Test-Dependencies/trunk/t/01-load-with-exclude.t
   Test-Dependencies/trunk/t/02-dependencies.t

Log:
 r11424 at galvatron:  zev | 2006-07-11 16:24:22 -0400
 * moved to a B::PerlReq backend for determining usage.
 * use the META.yml file to determine what is listed in Makefile.PL.
 * differentiate between requires and build_requires
 * complain if listed requirements are not actually used.
 * update Module::Install
 


Modified: Test-Dependencies/trunk/Changes
==============================================================================
--- Test-Dependencies/trunk/Changes	(original)
+++ Test-Dependencies/trunk/Changes	Tue Jul 11 16:24:30 2006
@@ -4,4 +4,11 @@
         First release, based on Jifty's 00-dependencies.t
 
 0.02    Wed Jun 21 16:34:14 EDT 2006
-        Minor POD cleanups
\ No newline at end of file
+        Minor POD cleanups
+
+0.03    Tue Jul 11 16:17:32 EDT 2006
+        Moved to a B::PerlReq backend for determining usage.  We
+        also now use the META.yml file to determine what is listed in
+        Makefile.PL.  We now differentiate between requires and
+        build_requires, and complain if listed requirements are not
+        actually used.

Modified: Test-Dependencies/trunk/MANIFEST
==============================================================================
--- Test-Dependencies/trunk/MANIFEST	(original)
+++ Test-Dependencies/trunk/MANIFEST	Tue Jul 11 16:24:30 2006
@@ -12,8 +12,8 @@
 inc/Module/Install/WriteAll.pm
 lib/Test/Dependencies.pm
 Makefile.PL
-MANIFEST
-META.yml			# Will be created by "make dist"
+MANIFEST			This list of files
+META.yml
 README
 t/00-load-basic.t
 t/01-load-with-exclude.t

Modified: Test-Dependencies/trunk/META.yml
==============================================================================
--- Test-Dependencies/trunk/META.yml	(original)
+++ Test-Dependencies/trunk/META.yml	Tue Jul 11 16:24:30 2006
@@ -1,6 +1,8 @@
 author: Zev Benjamin <zev at bestpractical.com>
+build_requires: 
+  Test::Builder::Tester: 0
 distribution_type: module
-generated_by: Module::Install version 0.59
+generated_by: Module::Install version 0.630
 license: perl
 name: Test-Dependencies
 no_index: 
@@ -8,6 +10,10 @@
     - inc
     - t
 requires: 
+  B::PerlReq: 0
+  File::Find::Rule: 0
   Module::CoreList: 0
-  Pod::Strip: 0
-version: 0.02
+  PerlReq::Utils: 0
+  Test::Builder::Module: 0
+  YAML: 0
+version: 0.03

Modified: Test-Dependencies/trunk/Makefile.PL
==============================================================================
--- Test-Dependencies/trunk/Makefile.PL	(original)
+++ Test-Dependencies/trunk/Makefile.PL	Tue Jul 11 16:24:30 2006
@@ -4,8 +4,15 @@
 author          'Zev Benjamin <zev at bestpractical.com>';
 version_from        'lib/Test/Dependencies.pm';
 license 'perl';
+
+requires('B::PerlReq');
+requires('File::Find::Rule');
 requires('Module::CoreList');
-requires('Pod::Strip');
+requires('PerlReq::Utils');
+requires('Test::Builder::Module');
+requires('YAML');
+
+build_requires('Test::Builder::Tester');
 
 auto_install;
 WriteAll;

Modified: Test-Dependencies/trunk/inc/Module/AutoInstall.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/AutoInstall.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/AutoInstall.pm	Tue Jul 11 16:24:30 2006
@@ -1,4 +1,4 @@
-#line 1 "inc/Module/AutoInstall.pm - /usr/local/share/perl/5.8.7/Module/AutoInstall.pm"
+#line 1
 package Module::AutoInstall;
 
 use strict;
@@ -639,7 +639,9 @@
 
     # check for version numbers that are not in decimal format
     if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) {
-        if ( $version::VERSION or defined( _load('version') ) ) {
+        if ( ( $version::VERSION or defined( _load('version') )) and
+             version->can('new') 
+            ) {
 
             # use version.pm if it is installed.
             return (
@@ -750,4 +752,4 @@
 
 __END__
 
-#line 988
+#line 990

Modified: Test-Dependencies/trunk/inc/Module/Install.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install.pm	Tue Jul 11 16:24:30 2006
@@ -1,6 +1,22 @@
-#line 1 "/home/jesse/svk/Test-Dependencies/trunk/inc/Module/Install.pm - /usr/local/share/perl/5.8.7/Module/Install.pm"
+#line 1
 package Module::Install;
 
+# For any maintainers:
+# The load order for Module::Install is a bit magic.
+# It goes something like this...
+#
+# IF ( host has Module::Install installed, creating author mode ) {
+#     1. Makefile.PL calls "use inc::Module::Install"
+#     2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install
+#     3. The installed version of inc::Module::Install loads
+#     4. inc::Module::Install calls "require Module::Install"
+#     5. The ./inc/ version of Module::Install loads
+# } ELSE {
+#     1. Makefile.PL calls "use inc::Module::Install"
+#     2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install
+#     3. The ./inc/ version of Module::Install loads
+# }
+
 use 5.004;
 use strict 'vars';
 
@@ -12,10 +28,15 @@
     # This is not enforced yet, but will be some time in the next few
     # releases once we can make sure it won't clash with custom
     # Module::Install extensions.
-    $VERSION = '0.59';
+    $VERSION = '0.63';
 }
 
-# inc::Module::Install must be loaded first
+# Whether or not inc::Module::Install is actually loaded, the
+# $INC{inc/Module/Install.pm} is what will still get set as long as
+# the caller loaded module this in the documented manner.
+# If not set, the caller may NOT have loaded the bundled version, and thus
+# they may not have a MI version that works with the Makefile.PL. This would
+# result in false errors or unexpected behaviour. And we don't want that.
 my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
 unless ( $INC{$file} ) {
     die <<"END_DIE";
@@ -30,6 +51,22 @@
 END_DIE
 }
 
+# If the script that is loading Module::Install is from the future,
+# then make will detect this and cause it to re-run over and over
+# again. This is bad. Rather than taking action to touch it (which
+# is unreliable on some platforms and requires write permissions)
+# for now we should catch this and refuse to run.
+if ( -f $0 and (stat($0))[9] > time ) {
+	die << "END_DIE";
+Your installer $0 has a modification time in the future.
+
+This is known to create infinite loops in make.
+
+Please correct this, then run $0 again.
+
+END_DIE
+}
+
 use Cwd        ();
 use File::Find ();
 use File::Path ();
@@ -95,7 +132,7 @@
     my %seen;
     foreach my $obj ( @exts ) {
         while (my ($method, $glob) = each %{ref($obj) . '::'}) {
-            next unless exists &{ref($obj).'::'.$method};
+            next unless $obj->can($method);
             next if $method =~ /^_/;
             next if $method eq uc($method);
             $seen{$method}++;
@@ -136,7 +173,7 @@
     }
     $args{file}     ||= "$args{base}/$args{prefix}/$args{path}.pm";
 
-    bless \%args, $class;
+    bless( \%args, $class );
 }
 
 sub call {
@@ -175,7 +212,6 @@
         unshift @INC, $self->{prefix};
     }
 
-    local @INC = ($path, @INC);
     foreach my $rv ( $self->find_extensions($path) ) {
         my ($file, $pkg) = @{$rv};
         next if $self->{pathnames}{$pkg};

Modified: Test-Dependencies/trunk/inc/Module/Install/AutoInstall.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/AutoInstall.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/AutoInstall.pm	Tue Jul 11 16:24:30 2006
@@ -1,12 +1,15 @@
-#line 1 "inc/Module/Install/AutoInstall.pm - /usr/local/share/perl/5.8.7/Module/Install/AutoInstall.pm"
+#line 1
 package Module::Install::AutoInstall;
 
+use strict;
 use Module::Install::Base;
- at ISA = qw{Module::Install::Base};
-
-$VERSION = '0.59';
 
-use strict;
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.63';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
 
 sub AutoInstall { $_[0] }
 

Modified: Test-Dependencies/trunk/inc/Module/Install/Base.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/Base.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/Base.pm	Tue Jul 11 16:24:30 2006
@@ -1,7 +1,7 @@
-#line 1 "inc/Module/Install/Base.pm - /usr/local/share/perl/5.8.7/Module/Install/Base.pm"
+#line 1
 package Module::Install::Base;
 
-$VERSION = '0.59';
+$VERSION = '0.63';
 
 # Suspend handler for "redefined" warnings
 BEGIN {

Modified: Test-Dependencies/trunk/inc/Module/Install/Can.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/Can.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/Can.pm	Tue Jul 11 16:24:30 2006
@@ -1,75 +1,82 @@
-#line 1 "inc/Module/Install/Can.pm - /usr/local/share/perl/5.8.7/Module/Install/Can.pm"
+#line 1
 package Module::Install::Can;
 
-use Module::Install::Base;
- at ISA = qw(Module::Install::Base);
-
-$VERSION = '0.59';
-
 use strict;
+use Module::Install::Base;
 use Config ();
+### This adds a 5.005 Perl version dependency.
+### This is a bug and will be fixed.
+use File::Spec ();
 use ExtUtils::MakeMaker ();
 
-# This may introduce a 5.005 dependency, or at the very least it may
-# not bootstrap properly under 5.004.
-use File::Spec ();
- 
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.63';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
+
 # check if we can load some module
+### Upgrade this to not have to load the module if possible
 sub can_use {
-    my ($self, $mod, $ver) = @_;
-    $mod =~ s{::|\\}{/}g;
-    $mod .= ".pm" unless $mod =~ /\.pm$/i;
-
-    my $pkg = $mod;
-    $pkg =~ s{/}{::}g;
-    $pkg =~ s{\.pm$}{}i;
+	my ($self, $mod, $ver) = @_;
+	$mod =~ s{::|\\}{/}g;
+	$mod .= '.pm' unless $mod =~ /\.pm$/i;
+
+	my $pkg = $mod;
+	$pkg =~ s{/}{::}g;
+	$pkg =~ s{\.pm$}{}i;
 
-    local $@;
-    eval { require $mod; $pkg->VERSION($ver || 0); 1 };
+	local $@;
+	eval { require $mod; $pkg->VERSION($ver || 0); 1 };
 }
 
 # check if we can run some command
 sub can_run {
-    my ($self, $cmd) = @_;
+	my ($self, $cmd) = @_;
 
-    my $_cmd = $cmd;
-    return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
+	my $_cmd = $cmd;
+	return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
 
-    for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
-        my $abs = File::Spec->catfile($dir, $_[1]);
-        return $abs if (-x $abs or $abs = MM->maybe_command($abs));
-    }
+	for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
+		my $abs = File::Spec->catfile($dir, $_[1]);
+		return $abs if (-x $abs or $abs = MM->maybe_command($abs));
+	}
 
-    return;
+	return;
 }
 
+# can we locate a (the) C compiler
 sub can_cc {
-    my $self = shift;
-    my @chunks = split(/ /, $Config::Config{cc}) or return;
+	my $self   = shift;
+	my @chunks = split(/ /, $Config::Config{cc}) or return;
 
-    # $Config{cc} may contain args; try to find out the program part
-    while (@chunks) {
-        return $self->can_run("@chunks") || (pop(@chunks), next);
-    }
+	# $Config{cc} may contain args; try to find out the program part
+	while (@chunks) {
+		return $self->can_run("@chunks") || (pop(@chunks), next);
+	}
 
-    return;
+	return;
 }
 
 # Fix Cygwin bug on maybe_command();
-if ($^O eq 'cygwin') {
-    require ExtUtils::MM_Cygwin;
-    require ExtUtils::MM_Win32;
-    if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
-        *ExtUtils::MM_Cygwin::maybe_command = sub {
-            my ($self, $file) = @_;
-            if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
-                ExtUtils::MM_Win32->maybe_command($file);
-            }
-            else {
-                ExtUtils::MM_Unix->maybe_command($file);
-            }
-        }
-    }
+if ( $^O eq 'cygwin' ) {
+	require ExtUtils::MM_Cygwin;
+	require ExtUtils::MM_Win32;
+	if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
+		*ExtUtils::MM_Cygwin::maybe_command = sub {
+			my ($self, $file) = @_;
+			if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
+				ExtUtils::MM_Win32->maybe_command($file);
+			} else {
+				ExtUtils::MM_Unix->maybe_command($file);
+			}
+		}
+	}
 }
 
 1;
+
+__END__
+
+#line 157

Modified: Test-Dependencies/trunk/inc/Module/Install/Fetch.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/Fetch.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/Fetch.pm	Tue Jul 11 16:24:30 2006
@@ -1,12 +1,13 @@
-#line 1 "inc/Module/Install/Fetch.pm - /usr/local/share/perl/5.8.7/Module/Install/Fetch.pm"
+#line 1
 package Module::Install::Fetch;
 
 use strict;
 use Module::Install::Base;
 
-use vars qw{$VERSION @ISA};
+use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.59';
+	$VERSION = '0.63';
+	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 

Modified: Test-Dependencies/trunk/inc/Module/Install/Include.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/Include.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/Include.pm	Tue Jul 11 16:24:30 2006
@@ -1,12 +1,15 @@
-#line 1 "inc/Module/Install/Include.pm - /usr/local/share/perl/5.8.7/Module/Install/Include.pm"
+#line 1
 package Module::Install::Include;
 
+use strict;
 use Module::Install::Base;
- at ISA = qw(Module::Install::Base);
-
-$VERSION = '0.59';
 
-use strict;
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.63';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
 
 sub include {
 	shift()->admin->include(@_);

Modified: Test-Dependencies/trunk/inc/Module/Install/Makefile.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/Makefile.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/Makefile.pm	Tue Jul 11 16:24:30 2006
@@ -1,13 +1,14 @@
-#line 1 "inc/Module/Install/Makefile.pm - /usr/local/share/perl/5.8.7/Module/Install/Makefile.pm"
+#line 1
 package Module::Install::Makefile;
 
 use strict 'vars';
 use Module::Install::Base;
 use ExtUtils::MakeMaker ();
 
-use vars qw{$VERSION @ISA};
+use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.59';
+	$VERSION = '0.63';
+	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 
@@ -68,6 +69,15 @@
     );
 }
 
+sub realclean_files {
+    my $self  = shift;
+    my $realclean = $self->makemaker_args->{realclean} ||= {};
+    %$realclean = (
+        %$realclean, 
+        FILES => join(' ', grep length, $realclean->{FILES}, @_),
+    );
+}
+
 sub libs {
     my $self = shift;
     my $libs = ref $_[0] ? shift : [ shift ];
@@ -132,7 +142,7 @@
     }
 
     my $mm = ExtUtils::MakeMaker::WriteMakefile(%args);
-    $self->fix_up_makefile($mm->{FIRST_MAKEFILE});
+    $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile');
 }
 
 sub fix_up_makefile {
@@ -159,6 +169,18 @@
     $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
     $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
 
+    # Module::Install will never be used to build the Core Perl
+    # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks
+    # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist
+    $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m;
+    #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m;
+
+    # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well.
+    $makefile =~ s/("?)-I\$\(PERL_LIB\)\1//g;
+
+    # XXX - This is currently unused; not sure if it breaks other MM-users
+    # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
+
     open  MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
     print MAKEFILE  "$preamble$makefile$postamble" or die $!;
     close MAKEFILE  or die $!;
@@ -183,4 +205,4 @@
 
 __END__
 
-#line 312
+#line 334

Modified: Test-Dependencies/trunk/inc/Module/Install/Metadata.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/Metadata.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/Metadata.pm	Tue Jul 11 16:24:30 2006
@@ -1,12 +1,15 @@
-#line 1 "inc/Module/Install/Metadata.pm - /usr/local/share/perl/5.8.7/Module/Install/Metadata.pm"
+#line 1
 package Module::Install::Metadata;
 
+use strict 'vars';
 use Module::Install::Base;
- at ISA = qw{Module::Install::Base};
-
-$VERSION = '0.59';
 
-use strict 'vars';
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.63';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
 
 my @scalar_keys = qw{
     name module_name abstract author version license
@@ -120,9 +123,9 @@
 
     require Module::Build;
     my $build = Module::Build->new(
-        dist_name    => $self->{name},
-        dist_version => $self->{version},
-        license      => $self->{license},
+        dist_name    => $self->name,
+        dist_version => $self->version,
+        license      => $self->license,
     );
     $self->provides(%{ $build->find_dist_packages || {} });
 }
@@ -235,11 +238,13 @@
         ^
         use \s*
         v?
-        ([\d\.]+)
+        ([\d_\.]+)
         \s* ;
     /ixms
       )
     {
+        my $v = $1;
+        $v =~ s{_}{}g;
         $self->perl_version($1);
     }
     else {

Modified: Test-Dependencies/trunk/inc/Module/Install/Win32.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/Win32.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/Win32.pm	Tue Jul 11 16:24:30 2006
@@ -1,42 +1,45 @@
-#line 1 "inc/Module/Install/Win32.pm - /usr/local/share/perl/5.8.7/Module/Install/Win32.pm"
+#line 1
 package Module::Install::Win32;
 
+use strict;
 use Module::Install::Base;
- at ISA = qw(Module::Install::Base);
-
-$VERSION = '0.59';
 
-use strict;
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.63';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
 
 # determine if the user needs nmake, and download it if needed
 sub check_nmake {
-    my $self = shift;
-    $self->load('can_run');
-    $self->load('get_file');
-
-    require Config;
-    return unless (
-        $Config::Config{make}                   and
-        $Config::Config{make} =~ /^nmake\b/i    and
-        $^O eq 'MSWin32'                        and
-        !$self->can_run('nmake')
-    );
-
-    print "The required 'nmake' executable not found, fetching it...\n";
-
-    require File::Basename;
-    my $rv = $self->get_file(
-        url         => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
-        ftp_url     => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
-        local_dir   => File::Basename::dirname($^X),
-        size        => 51928,
-        run         => 'Nmake15.exe /o > nul',
-        check_for   => 'Nmake.exe',
-        remove      => 1,
-    );
+	my $self = shift;
+	$self->load('can_run');
+	$self->load('get_file');
+	
+	require Config;
+	return unless (
+		$^O eq 'MSWin32'                     and
+		$Config::Config{make}                and
+		$Config::Config{make} =~ /^nmake\b/i and
+		! $self->can_run('nmake')
+	);
+
+	print "The required 'nmake' executable not found, fetching it...\n";
+
+	require File::Basename;
+	my $rv = $self->get_file(
+		url       => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
+		ftp_url   => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
+		local_dir => File::Basename::dirname($^X),
+		size      => 51928,
+		run       => 'Nmake15.exe /o > nul',
+		check_for => 'Nmake.exe',
+		remove    => 1,
+	);
 
-    if (!$rv) {
-        die << '.';
+	if (!$rv) {
+        die <<'END_MESSAGE';
 
 -------------------------------------------------------------------------------
 
@@ -55,11 +58,8 @@
 You may then resume the installation process described in README.
 
 -------------------------------------------------------------------------------
-.
-    }
+END_MESSAGE
+	}
 }
 
 1;
-
-__END__
-

Modified: Test-Dependencies/trunk/inc/Module/Install/WriteAll.pm
==============================================================================
--- Test-Dependencies/trunk/inc/Module/Install/WriteAll.pm	(original)
+++ Test-Dependencies/trunk/inc/Module/Install/WriteAll.pm	Tue Jul 11 16:24:30 2006
@@ -1,12 +1,15 @@
-#line 1 "inc/Module/Install/WriteAll.pm - /usr/local/share/perl/5.8.7/Module/Install/WriteAll.pm"
+#line 1
 package Module::Install::WriteAll;
 
+use strict;
 use Module::Install::Base;
- at ISA = qw(Module::Install::Base);
-
-$VERSION = '0.59';
 
-use strict;
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.63';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
 
 sub WriteAll {
     my $self = shift;

Modified: Test-Dependencies/trunk/lib/Test/Dependencies.pm
==============================================================================
--- Test-Dependencies/trunk/lib/Test/Dependencies.pm	(original)
+++ Test-Dependencies/trunk/lib/Test/Dependencies.pm	Tue Jul 11 16:24:30 2006
@@ -3,14 +3,14 @@
 use warnings;
 use strict;
 
+use B::PerlReq;
 use Carp;
-use File::Find;
+use File::Find::Rule;
 use Module::CoreList;
-use Pod::Strip;
-use Test::More qw(no_plan);
+use PerlReq::Utils qw(path2mod);
+use YAML qw(LoadFile);
 
-use Exporter;
-our @ISA = qw/Exporter/;
+use base 'Test::Builder::Module';
 
 =head1 NAME
 
@@ -18,11 +18,11 @@
 
 =head1 VERSION
 
-Version 0.02
+Version 0.03
 
 =cut
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 =head1 SYNOPSIS
 
@@ -45,6 +45,12 @@
 our $exclude_re;
 
 sub import {
+  my $package = $_[0];
+  my $callerpack = caller;
+  my $tb = __PACKAGE__->builder;
+  $tb->exported_to($callerpack);
+  $tb->no_plan;
+
   if (scalar @_ == 3) {
     # package name, literal exclude, excluded namespaces
     my $exclude = $_[2];
@@ -54,67 +60,147 @@
     }
     $exclude_re = join '|', @$exclude;
   } elsif (scalar @_ != 1) {
-    croak "wrong number of arguments while using Test::Dependencies";
+    croak "wrong number of arguments while using Test::Dependencies: " . join ' ', @_;
   }
-  Test::Dependencies->export_to_level(1, '', qw/ok_dependencies/);
+  $package->export_to_level(1, '', qw/ok_dependencies/);
 }
 
-sub ok_dependencies {
-  my %used;
+sub _get_files_in {
+  my @dirs = @_;
+  my $rule = File::Find::Rule->new;
+  $rule->or($rule->new
+                 ->directory
+                 ->name('.svn')
+                 ->prune
+                 ->discard,
+            $rule->new
+                 ->directory
+                 ->name('CVS')
+                 ->prune
+                 ->discard,
+            $rule->new
+                 ->name(qr/~$/)
+                 ->discard,
+            $rule->new
+                 ->name(qr/\.pod$/)
+                 ->discard,
+            $rule->new
+                 ->not($rule->new->file)
+                 ->discard,
+            $rule->new);
+  return $rule->in(grep {-e $_} @dirs);
+}
 
-  my $wanted = sub {
-    return unless -f $_;
-    return if $File::Find::dir =~ m!/.svn($|/)!;
-    return if $File::Find::name =~ /~$/;
-    return if $File::Find::name =~ /\.pod$/;
-    local $/;
-    open(FILE, $_) or return;
-    my $data = <FILE>;
-    close(FILE);
-    my $p = Pod::Strip->new;
-    my $code;
-    $p->output_string(\$code);
-    $p->parse_string_document($data);
-    $used{$1}++ while $code =~ /^\s*use\s+([\w:]+)/gm;
-    while ($code =~ m|^\s*use base qw.([\w\s:]+)|gm) {
-      $used{$_}++ for split ' ', $1;
-    }
-  };
+sub _taint_flag {
+  my $filename = shift;
+  open FILE, $filename;
+  my $shebang = <FILE>;
+  close FILE;
+  chomp $shebang;
+  if ($shebang =~ m/^#!.*perl.*-T/) {
+    return '-T';
+  } else {
+    return '';
+  }
+}
 
-  for my $dir (qw/ lib bin t /) {
-    if ( -e $dir) {
-      find( { wanted => $wanted,
-              untaint => 1}, $dir);
-    }
+sub _get_modules_used_in {
+  my @dirs = @_;
+  my @sourcefiles = _get_files_in(@dirs);
+  my $perl = $^X;
+  my %deps;
+  foreach my $file (@sourcefiles) {
+    my $taint = _taint_flag($file);
+    my $output = `$perl $taint -MO=PerlReq '$file' 2> /dev/null`;
+    # path2mod sucks, but the mod2path that B::PerlReq uses sucks, too
+    my @filedeps = map { s/^perl\((.+)\)$/$1/; path2mod($_) }
+               split /\n/, $output;
+    $deps{$_}++ foreach @filedeps;
   }
+  return keys %deps;
+}
 
-  my %required;
-  { 
-    local $/;
-    ok(open(MAKEFILE,"Makefile.PL"), "Opened Makefile");
-    my $data = <MAKEFILE>;
-    close(FILE);
-    while ($data =~ /^\s*?requires\('([\w:]+)'(?:\s*=>\s*['"]?([\d\.]+)['"]?)?.*?(?:#(.*))?$/gm) {
-      $required{$1} = $2;
-      if (defined $3 and length $3) {
-        $required{$_} = undef for split ' ', $3;
-      }
+sub _get_used {
+  return _get_modules_used_in(qw/bin lib/);
+}
+
+sub _get_build_used {
+  return _get_modules_used_in(qw/t/);
+}
+
+=head1 EXPORTED FUNCTIONS
+
+=head2 ok_dependencies
+
+This should be the only test called in the test file.  It scans
+bin/ and lib/ for module usage and t/ for build usage.  It will
+then test that all modules used are listed as required in
+Makefile.PL, all modules used in t/ are listed as build required,
+that all modules listed are actually used, and that modules that
+are listed are not in the core list.
+
+=cut
+
+sub ok_dependencies {
+  my $tb = __PACKAGE__->builder;
+  my %used = map { $_ => 1 } _get_used;
+  my %build_used = map { $_ => 1 } _get_build_used;
+
+  # remove modules from build deps if they are hard deps
+  foreach my $mod (keys %used) {
+    delete $build_used{$mod} if exists $build_used{$mod};
+  }
+  
+  my $meta = LoadFile('META.yml') or die 'Could not load META.YML';
+  my %required = exists $meta->{requires} ? %{$meta->{requires}} : ();
+  my %build_required = exists $meta->{build_requires} ? %{$meta->{build_requires}} : ();
+
+  my @in_core;
+  
+  foreach my $mod (sort keys %used) {
+    my $first_in = Module::CoreList->first_release($mod);
+    if (defined $first_in and $first_in <= 5.00803) {
+      delete $used{$mod};
+      push @in_core, $mod if exists $required{$mod};
+      next;
+    }
+    if (defined $exclude_re && $mod =~ m/^($exclude_re)(::|$)/) {
+      delete $used{$mod};
+      next;
     }
+    $tb->ok(exists $required{$mod}, "requires('$mod') in Makefile.PL");
+    delete $used{$mod};
+    delete $required{$mod};
   }
 
-  for (sort keys %used) {
-    my $first_in = Module::CoreList->first_release($_);
-    next if defined $first_in and $first_in <= 5.00803;
-    next if /^($exclude_re)(::|$)/;
-    ok(exists $required{$_}, "$_ in Makefile.PL");
-    delete $used{$_};
-    delete $required{$_};
+  foreach my $mod (sort keys %build_used) {
+    my $first_in = Module::CoreList->first_release($mod);
+    if (defined $first_in and $first_in <= 5.00803) {
+      delete $build_used{$mod};
+      push @in_core, $mod if exists $build_required{$mod};
+      next;
+    }
+    if (defined $exclude_re && $mod =~ m/^($exclude_re)(::|$)/) {
+      delete $build_used{$mod};
+      next;
+    }
+    $tb->ok(exists $build_required{$mod}, "build_requires('$mod') in Makefile.PL");
+    delete $build_used{$mod};
+    delete $build_required{$mod};
+  }  
+
+  foreach my $mod (sort @in_core) {
+    $tb->ok(0, "Required module $mod is already in core");
+  }
+  
+  foreach my $mod (sort keys %required) {
+    $tb->ok(0, "$mod is not a dependency");
   }
 
-  for (sort keys %required) {
-    my $first_in = Module::CoreList->first_release($_, $required{$_});
-    fail("Required module $_ is already in core") if defined $first_in and $first_in <= 5.00803;
+  foreach my $mod (sort keys %build_required) {
+    $tb->ok(0, "$mod is not a build dependency");
   }
+
 }
 
 =head1 AUTHORS
@@ -131,6 +217,14 @@
 
 =head1 BUGS
 
+=over 4
+
+=item * Test::Dependencies does not track module version requirements.
+
+=item * Perl version for "already in core" test failures is hardcoded.
+
+=back
+
 Please report any bugs or feature requests to
 C<bug-test-dependencies at rt.cpan.org>, or through the web interface at
 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Dependencies>.
@@ -165,9 +259,8 @@
 
 =back
 
-=head1 ACKNOWLEDGEMENTS
+=head1 LICENCE AND COPYRIGHT
 
-LICENCE AND COPYRIGHT
     Copyright (c) 2006, Best Practical Solutions, LLC. All rights reserved.
 
     This module is free software; you can redistribute it and/or modify it

Modified: Test-Dependencies/trunk/t/00-load-basic.t
==============================================================================
--- Test-Dependencies/trunk/t/00-load-basic.t	(original)
+++ Test-Dependencies/trunk/t/00-load-basic.t	Tue Jul 11 16:24:30 2006
@@ -1,8 +1,10 @@
 #!perl -T
 
-# don't specify a plan so that we don't plan twice
-use Test::More;
+use Test::Builder::Tester;
+use Test::More tests => 1;
 
 BEGIN {
-	use_ok( 'Test::Dependencies' );
+  test_pass("use Test::Dependencies;");
+  use_ok('Test::Dependencies');
+  test_test("use Test::Dependencies;");
 }

Modified: Test-Dependencies/trunk/t/01-load-with-exclude.t
==============================================================================
--- Test-Dependencies/trunk/t/01-load-with-exclude.t	(original)
+++ Test-Dependencies/trunk/t/01-load-with-exclude.t	Tue Jul 11 16:24:30 2006
@@ -1,9 +1,11 @@
 #!perl -T
 
-# don't specify a plan so that we don't plan twice
-use Test::More;
+use Test::Builder::Tester;
+use Test::More tests => 1;
 
 BEGIN {
-	use_ok( 'Test::Dependencies', 'exclude',
-                [qw/Some::Namespace Some::Other::Namespace/] );
+  test_pass("use Test::Dependencies;");
+  use_ok( 'Test::Dependencies', 'exclude',
+          [qw/Some::Namespace Some::Other::Namespace/] );
+  test_test("use Test::Dependencies;");
 }

Modified: Test-Dependencies/trunk/t/02-dependencies.t
==============================================================================
--- Test-Dependencies/trunk/t/02-dependencies.t	(original)
+++ Test-Dependencies/trunk/t/02-dependencies.t	Tue Jul 11 16:24:30 2006
@@ -1,6 +1,6 @@
-#!perl -T
+#!perl
 
 # yay bootstrap!
 use Test::Dependencies exclude => [qw/Test::Dependencies/];
 
-ok_dependencies();
\ No newline at end of file
+ok_dependencies();


More information about the Rt-commit mailing list