r30601 - in /branches/upstream/libtest-prereq-perl: ./ current/ current/examples/ current/lib/ current/t/ current/testdir/ current/testdir/bad_makefile/

rmayorga at users.alioth.debian.org rmayorga at users.alioth.debian.org
Thu Feb 12 03:56:58 UTC 2009


Author: rmayorga
Date: Thu Feb 12 03:56:39 2009
New Revision: 30601

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=30601
Log:
[svn-inject] Installing original source of libtest-prereq-perl

Added:
    branches/upstream/libtest-prereq-perl/
    branches/upstream/libtest-prereq-perl/current/
    branches/upstream/libtest-prereq-perl/current/Changes
    branches/upstream/libtest-prereq-perl/current/LICENSE
    branches/upstream/libtest-prereq-perl/current/MANIFEST
    branches/upstream/libtest-prereq-perl/current/META.yml
    branches/upstream/libtest-prereq-perl/current/Makefile.PL
    branches/upstream/libtest-prereq-perl/current/README
    branches/upstream/libtest-prereq-perl/current/examples/
    branches/upstream/libtest-prereq-perl/current/examples/README
    branches/upstream/libtest-prereq-perl/current/lib/
    branches/upstream/libtest-prereq-perl/current/lib/Build.pm
    branches/upstream/libtest-prereq-perl/current/lib/Prereq.pm
    branches/upstream/libtest-prereq-perl/current/t/
    branches/upstream/libtest-prereq-perl/current/t/get_from_file.t
    branches/upstream/libtest-prereq-perl/current/t/get_from_prereqs.t
    branches/upstream/libtest-prereq-perl/current/t/get_loaded_modules.t
    branches/upstream/libtest-prereq-perl/current/t/get_prereqs.t
    branches/upstream/libtest-prereq-perl/current/t/import.t
    branches/upstream/libtest-prereq-perl/current/t/load.t
    branches/upstream/libtest-prereq-perl/current/t/pod.t
    branches/upstream/libtest-prereq-perl/current/t/pod_coverage.t
    branches/upstream/libtest-prereq-perl/current/t/prereq_ok.t
    branches/upstream/libtest-prereq-perl/current/t/prior_plan.t
    branches/upstream/libtest-prereq-perl/current/t/test_manifest
    branches/upstream/libtest-prereq-perl/current/testdir/
    branches/upstream/libtest-prereq-perl/current/testdir/Build.PL
    branches/upstream/libtest-prereq-perl/current/testdir/MANIFEST
    branches/upstream/libtest-prereq-perl/current/testdir/bad_makefile/
    branches/upstream/libtest-prereq-perl/current/testdir/bad_makefile/Makefile.PL

Added: branches/upstream/libtest-prereq-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/Changes?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/Changes (added)
+++ branches/upstream/libtest-prereq-perl/current/Changes Thu Feb 12 03:56:39 2009
@@ -1,0 +1,96 @@
+# $Id$
+
+1.36 - Mon Jan 19 16:48:16 2009
+	* RT #42539: Fixed problem recognizing modules included in
+	the dist (Brian Phillips)
+
+1.035 - Sat Aug  2 23:24:14 2008
+	* Cleaning up the Makefile a bit. No need to upgrade.
+
+1.034 - Sat Jul 12 21:32:16 2008
+	* Various minor cleanups. No bg whoop.
+
+1.033 - Fri Mar 16 23:00:57 2007
+	* Fixed load test to not complain when trying to import the same
+	symbol twice
+	* No code fixes otherwise. No need to upgrade.
+
+1.032 - Tue Jan  9 22:54:40 2007
+	* updated copyright and license info
+	* no code changes, so no need to upgrade
+
+1.031 - Wed May 17 22:23:23 2006
+	* updates to distro and kwalitee. No need to upgrade
+
+1.30 - Wed May 17 22:15:01 2006
+	* Updates to distro and kwalitee. No need to upgrade.
+
+1.30 - Wed Jan 11 00:11:21 2006
+	* Tests should now work even if there is nothing in PREREQ_PM. In the
+	previous version, an empty PREREQ_PM made the module think Makefile.PL
+	didn't exit cleanly. 
+	* Everyone should upgrade.
+
+1.29 - Sun Dec 25 20:03:47 2005
+	* Updated some tests that had some problems. No need to upgrade.
+
+1.028 - Wed Jul 13 17:31:13 2005
+	* Simple doc fixes. No need to upgrade.
+
+1.027 - Tue Mar  8 00:18:28 2005
+	* fixed up the bits that deal with the plan, to make things
+	consistent. prereq_ok will create the plan if it doesn't
+	exist, or leave it alone if it does.
+	* You don't need to use Test::More (and you didn't need
+	to previously, despite the docs)
+
+1.026 - Fri Mar  4 08:09:41 2005
+	* Documentation fix for command line invocation: Test::Prereq
+	calls plan() for you, so you don't have to.
+
+1.025 - Wed Sep  8 00:59:57 2004
+	* get rid of the 'redefine' warning when we read the Makefile.PL
+
+1.024 - Tue Sep  7 19:52:30 2004
+	* cleaned up distro
+	* bumped version to a full release (the interface is pretty much set)
+	* no need to upgrade really (although some modules might require a
+	version number above 1.x
+
+0.23 - Tue Aug 24 19:58:53 2004
+	* Changed a few things for demo talk
+
+0.23 - Fri Feb 20 05:42:18 2004
+	* got rid of the File::Find::Rule dependency
+
+0.19 - Fri Dec 20 16:18:39 2002
+	* stripped bad whitespace from Pod, no code changes
+
+0.18 Mon Nov  4 19:25:56 CST 2002
+	- skip CPANPLUS modules by default.  still haven't
+	figured this out. 
+	
+0.17 Wed Oct 23 11:55:28 CDT 2002
+	- removed extra call to CPAN.pm.  this should make 
+	things run faster.
+	
+0.16 Fri Oct 11 03:46:12 CDT 2002
+	- add MAN3PODS to WriteMakefile to make man
+	pages show up in the right place
+	
+0.15 Thu Oct 10 19:34:20 CDT 2002
+	- more changes to get around CPANPLUS
+	
+0.14 Thu Oct 10 17:19:27 CDT 2002
+	- test suite gives better error output (so i can
+	figure out what's up with CPANPLUS)
+	
+0.13 Wed Oct  9 19:37:47 EDT 2002
+	- expands distributions in PREREQ_PM to look for
+	modules implicitly declared
+
+0.10 Fri Oct  4 18:27:57 CDT 2002
+	- added support for Module::Build
+
+0.07 Mon Sep 30 00:53:19 PDT 2002
+	- cleaned up Makefile.PL for perl5.8.0 weirdness

Added: branches/upstream/libtest-prereq-perl/current/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/LICENSE?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/LICENSE (added)
+++ branches/upstream/libtest-prereq-perl/current/LICENSE Thu Feb 12 03:56:39 2009
@@ -1,0 +1,1 @@
+You can use Test::Prereq under the same terms as Perl itself.

Added: branches/upstream/libtest-prereq-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/MANIFEST?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/MANIFEST (added)
+++ branches/upstream/libtest-prereq-perl/current/MANIFEST Thu Feb 12 03:56:39 2009
@@ -1,0 +1,23 @@
+Changes
+examples/README
+lib/Build.pm
+lib/Prereq.pm
+LICENSE
+Makefile.PL
+MANIFEST			This list of files
+README
+t/get_from_file.t
+t/get_from_prereqs.t
+t/get_loaded_modules.t
+t/get_prereqs.t
+t/import.t
+t/load.t
+t/pod.t
+t/pod_coverage.t
+t/prereq_ok.t
+t/prior_plan.t
+t/test_manifest
+testdir/bad_makefile/Makefile.PL
+testdir/Build.PL
+testdir/MANIFEST
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libtest-prereq-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/META.yml?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/META.yml (added)
+++ branches/upstream/libtest-prereq-perl/current/META.yml Thu Feb 12 03:56:39 2009
@@ -1,0 +1,25 @@
+--- #YAML:1.0
+name:               Test-Prereq
+version:            1.036
+abstract:           check if Makefile.PL has the right pre-requisites
+author:
+    - brian d foy <bdfoy at cpan.org>
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Module::Build:        0
+    Module::CoreList:     0
+    Module::Info:         0
+    Test::Builder:        0
+    Test::Builder::Tester:  0
+    Test::More:           0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.48
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Added: branches/upstream/libtest-prereq-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/Makefile.PL?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/Makefile.PL (added)
+++ branches/upstream/libtest-prereq-perl/current/Makefile.PL Thu Feb 12 03:56:39 2009
@@ -1,0 +1,39 @@
+# $Id$
+use ExtUtils::MakeMaker;
+
+require 5.006;
+
+eval "use Test::Manifest 1.14";
+
+WriteMakefile(
+	'NAME'            => 'Test::Prereq',
+	'VERSION_FROM'    => 'lib/Prereq.pm',
+	'ABSTRACT'        => 'check if Makefile.PL has the right pre-requisites',	
+	'LICENSE'   	  => 'perl',
+	'AUTHOR'          => 'brian d foy <bdfoy at cpan.org>',
+
+	'PREREQ_PM' => {
+		'Module::Build'         => '0',
+		'Module::CoreList'      => '0',
+		'Module::Info'          => '0',
+		'Test::Builder'         => '0',
+		'Test::Builder::Tester' => '0',
+		'Test::More'            => '0',
+		},
+
+	'PM'        => 
+		{
+		'lib/Prereq.pm'  => '$(INST_LIBDIR)/Prereq.pm',
+		'lib/Build.pm'   => '$(INST_LIBDIR)/Prereq/Build.pm',
+		},
+
+	'MAN3PODS' =>
+		{
+		'lib/Prereq.pm' => '$(INST_MAN3DIR)/Test::Prereq.3',
+		'lib/Build.pm'  => '$(INST_MAN3DIR)/Test::Prereq::Build.3',
+		},
+
+	clean  => { FILES => 'Test-Prereq-*' },
+	);
+
+1;

Added: branches/upstream/libtest-prereq-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/README?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/README (added)
+++ branches/upstream/libtest-prereq-perl/current/README Thu Feb 12 03:56:39 2009
@@ -1,0 +1,27 @@
+$Id$
+
+You can install this using in the usual Perl fashion
+
+	perl Makefile.PL
+	make
+	make test
+	make install
+	
+The documentation is in the module file.  Once you install
+the file, you can read it with perldoc.
+
+	perldoc Test::Prereq
+	
+If you want to read it before you install it, you can use
+perldoc directly on the module file.
+
+	perldoc lib/Prereq.pm
+	
+This module is also in CVS on SourceForge
+
+	http://sourceforge.net/projects/brian-d-foy/
+
+
+Enjoy, 
+
+brian d foy, bdfoy at cpan.org

Added: branches/upstream/libtest-prereq-perl/current/examples/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/examples/README?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/examples/README (added)
+++ branches/upstream/libtest-prereq-perl/current/examples/README Thu Feb 12 03:56:39 2009
@@ -1,0 +1,1 @@
+See the tests in the t/ directory for examples until I add some more.

Added: branches/upstream/libtest-prereq-perl/current/lib/Build.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/lib/Build.pm?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/lib/Build.pm (added)
+++ branches/upstream/libtest-prereq-perl/current/lib/Build.pm Thu Feb 12 03:56:39 2009
@@ -1,0 +1,92 @@
+# $Id$
+package Test::Prereq::Build;
+use strict;
+
+use base qw(Test::Prereq);
+use vars qw($VERSION @EXPORT);
+
+use warnings;
+no warnings;
+
+=head1 NAME
+
+Test::Prereq::Build - test prerequisites in Module::Build scripts
+
+=head1 SYNOPSIS
+
+   use Test::Prereq::Build;
+   prereq_ok();
+
+=cut
+
+$VERSION = '1.036';
+
+use Module::Build;
+use Test::Builder;
+
+my $Test = Test::Builder->new;
+
+=head1 METHODS
+
+If you have problems, send me your Build.PL.
+
+This module overrides methods in Test::Prereq to make it work with
+Module::Build.
+
+This module does not have any public methods.  See L<Test::Prereq>.
+
+=head1 AUTHOR
+
+brian d foy, C<< <bdfoy at cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2002-2009 brian d foy.  All rights reserved.
+
+This program is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+
+sub import 
+	{
+	my $self   = shift;
+	my $caller = caller;
+	no strict 'refs';
+	*{$caller.'::prereq_ok'}       = \&prereq_ok;
+	
+	$Test->exported_to($caller);
+	$Test->plan(@_);
+	}
+
+sub prereq_ok
+	{
+	$Test->plan( tests => 1 ) unless $Test->has_plan;
+	__PACKAGE__->_prereq_check( @_ );
+	}
+
+sub _master_file { 'Build.PL' }
+
+# override Module::Build
+sub Module::Build::new
+	{
+	my $class = shift;
+
+	my %hash = @_;
+
+	my @requires = sort grep $_ ne 'perl', (
+		keys %{ $hash{requires} },
+		keys %{ $hash{build_requires} },
+		);
+
+	@Test::Prereq::prereqs = @requires;
+
+	# intercept further calls to this object
+	return bless {}, __PACKAGE__;
+	}
+
+# fake Module::Build methods
+sub create_build_script { 1 };
+
+1;

Added: branches/upstream/libtest-prereq-perl/current/lib/Prereq.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/lib/Prereq.pm?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/lib/Prereq.pm (added)
+++ branches/upstream/libtest-prereq-perl/current/lib/Prereq.pm Thu Feb 12 03:56:39 2009
@@ -1,0 +1,479 @@
+#$Id$
+package Test::Prereq;
+use strict;
+
+use warnings;
+no warnings;
+
+=head1 NAME
+
+Test::Prereq - check if Makefile.PL has the right pre-requisites
+
+=head1 SYNOPSIS
+
+	# if you use Makefile.PL
+	use Test::More;
+	eval "use Test::Prereq";
+	plan skip_all => "Test::Prereq required to test dependencies" if $@;
+	prereq_ok();
+
+	# specify a perl version, test name, or module names to skip
+	prereq_ok( $version, $name, \@skip );
+
+	# if you use Module::Build
+	use Test::More;
+	eval "use Test::Prereq::Build";
+	plan skip_all => "Test::Prereq::Build required to test dependencies" if $@;
+	prereq_ok();
+
+	# or from the command line for a one-off check
+	perl -MTest::Prereq -eprereq_ok
+
+=head1 DESCRIPTION
+
+The prereq_ok() function examines the modules it finds in blib/lib/,
+blib/script, and the test files it finds in t/ (and test.pl). It
+figures out which modules they use, skips the modules that are in the
+Perl core, and compares the remaining list of modules to those in the
+PREREQ_PM section of Makefile.PL.
+
+If you use Module::Build instead, see L<Test::Prereq::Build> instead.
+
+=head2 Modules Test::Prereq can't find
+
+Module::Info only tells Test::Prereq which modules you used, not which
+distribution they came in.  This can be a problem for things in
+packages like libnet, libwww, Tk, and so on. At the moment
+Test::Prereq asks CPAN.pm to expand anything in PREREQ_PM to see if
+one of the distributions you explicity list contains the module you
+actually used.  This might fail in some cases.  Please send me
+anything that does not do what you think it should.
+
+Test::Prereq only asks CPAN.pm for help if it needs it, since CPAN.pm
+can be slow if it has to fetch things from the network. Once it
+fetches the right things, it should be much faster.
+
+=head2 Problem with Module::Info
+
+Module::Info appears to do something weird if a file it analyzes
+does not use (or require) any modules.  You may get a message like
+
+  Can't locate object method "name" via package "B::NULL" at
+  /usr/perl5.8.0/lib/site_perl/5.8.0/B/Module/Info.pm line 176.
+
+Also, if a file cannot compile, Module::Info dumps a lot of text
+to the terminal.  You probably want to bail out of testing if the
+files do not compile, though.
+
+=head2 Problem with CPANPLUS
+
+CPANPLUS apparently does some weird things, and since it is still
+young and not part of the Standard Library, Test::Prereq's tests do
+not do the right thing under it (for some reason).  Test::Prereq
+cheats by ignoring CPANPLUS completely in the tests---at least until
+someone has a better solution.  If you do not like that, you can set
+$EXCLUDE_CPANPLUS to a false value.
+
+You should be able to do a 'make test' manually to make everything
+work, though.
+
+=head2 Warning about redefining ExtUtils::MakeMaker::WriteMakefile
+
+Test::Prereq has its own version of ExtUtils::MakeMaker::WriteMakefile
+so it can run the Makefile.PL and get the argument list of that
+function.  You may see warnings about this.
+
+=cut
+
+use base qw(Exporter);
+use vars qw($VERSION $EXCLUDE_CPANPLUS @EXPORT @prereqs);
+
+
+$VERSION = '1.036';
+
+ at EXPORT = qw( prereq_ok );
+
+use Carp qw(carp);
+use CPAN;
+use ExtUtils::MakeMaker;
+use File::Find;
+use Module::CoreList;
+use Module::Info;
+use Test::Builder;
+use Test::More;
+
+my $Test = Test::Builder->new;
+
+my $Namespace = '';
+
+$EXCLUDE_CPANPLUS = 1;
+
+{
+no warnings;
+
+* ExtUtils::MakeMaker::WriteMakefile = sub
+	{
+	my %hash = @_;
+
+	my $name = $hash{NAME};
+	my $hash = $hash{PREREQ_PM};
+
+	$Namespace = $name;
+	@Test::Prereq::prereqs   = sort keys %$hash;
+	
+	1;
+	}
+}
+
+#unless( caller ) { prereq_ok() }
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item prereq_ok( [ VERSION, [ NAME [, SKIP_ARRAY] ] ] )
+
+Tests Makefile.PL to ensure all non-core module dependencies
+are in PREREQ_PM. If you haven't set a testing plan already,
+prereq_ok() creates a plan of one test.
+
+If you don't specify a version, prereq_ok assumes you want
+to compare the list of prerequisite modules to version
+5.008005.
+
+Valid versions come from Module::CoreList (which uses $[).
+
+	#!/usr/bin/perl
+	use Module::CoreList;
+	print map "$_\n", sort keys %Module::CoreList::version;
+
+
+	5.00307
+	5.004
+	5.00405
+	5.005
+	5.00503
+	5.00504
+	5.006
+	5.006001
+	5.006002
+	5.007003
+	5.008
+	5.008001
+	5.008002
+	5.008003
+	5.008004
+	5.008005
+	5.009
+	5.009001
+
+prereq_ok attempts to remove modules found in blib and
+libraries found in t from the reported prerequisites.
+
+The optional third argument is an array reference to a list
+of names that prereq_ok should ignore. You might want to use
+this if your tests do funny things with require.
+
+=cut
+
+my $default_version = '5.008005';
+my $version         = '5.008005';
+
+sub prereq_ok
+	{
+	$Test->plan( tests => 1 ) unless $Test->has_plan;
+	__PACKAGE__->_prereq_check( @_ );
+	}
+
+sub import 
+	{
+    my $self   = shift;
+    my $caller = caller;
+    no strict 'refs';
+    *{$caller.'::prereq_ok'}       = \&prereq_ok;
+
+    $Test->exported_to($caller);
+    $Test->plan(@_);
+	}
+
+sub _prereq_check
+	{
+	my $class   = shift;
+
+	   $version  = shift || $default_version;
+	my $name     = shift || 'Prereq test';
+	my $skip     = shift || [];
+
+	$version = $default_version unless
+		exists $Module::CoreList::version{$version};
+
+	unless( UNIVERSAL::isa( $skip, 'ARRAY' ) )
+		{
+		carp( 'Third parameter to prereq_ok must be an array reference!' );
+		return;
+		}
+
+	# get the declared prereqs from the Makefile.PL
+	my $prereqs = $class->_get_prereqs();
+	unless( $prereqs )
+		{
+		$class->_not_ok( "\t" .
+			$class->_master_file . " did not return a true value.\n" );
+		return 0;
+		}
+	
+	my $loaded  = $class->_get_loaded_modules();
+	
+	unless( $loaded )
+		{
+		$class->_not_ok( "\tCouldn't look up the modules for some reasons.\n" ,
+			"\tDo the blib/lib and t directories exist?\n",
+			);
+		return 0;
+		}
+
+	# remove modules found in PREREQ_PM
+	foreach my $module ( @$prereqs )
+		{
+		delete $loaded->{$module};
+		}
+
+	# remove modules found in distribution
+	my $distro = $class->_get_dist_modules( 'blib/lib' );
+	foreach my $module ( @$distro )
+		{
+		delete $loaded->{$module};
+		}
+
+	# remove modules found in test directory
+	$distro = $class->_get_test_libraries();
+	foreach my $module ( @$distro )
+		{
+		delete $loaded->{$module};
+		}
+
+	# remove modules in the skip array
+	foreach my $module ( @$skip )
+		{
+		delete $loaded->{$module};
+		}
+
+	# if anything is left, look for modules in the distributions
+	# in PREREQ_PM.  this is slow, so we should only do it if
+	# we might need it.
+	if( keys %$loaded )
+		{
+		my $modules = $class->_get_from_prereqs( $prereqs );
+
+		foreach my $module ( @$modules )
+			{
+			delete $loaded->{$module};
+			}
+		}
+
+	if( $EXCLUDE_CPANPLUS )
+		{
+		foreach my $module ( keys %$loaded )
+			{
+			next unless $module =~ m/^CPANPLUS::/;
+			delete $loaded->{$module};
+			}
+		}
+
+	if( keys %$loaded ) # stuff left in %loaded, oops!
+		{
+		$class->_not_ok( "Found some modules that didn't show up in PREREQ_PM\n",
+			map { "\t$_\n" } sort keys %$loaded );
+		}
+	else
+		{
+		$Test->ok( 1, $name );
+		}
+	
+	return 1;
+	}
+
+sub _not_ok
+	{
+	my( $self, $name, @message ) = @_;
+
+	$Test->ok( 0, $name );
+	$Test->diag( join "", @message );
+	}
+	
+sub _master_file { 'Makefile.PL' }
+
+sub _get_prereqs
+	{
+	my $class = shift;
+	my $file = $class->_master_file;
+
+	delete $INC{$file};  # make sure we load it again
+
+	{
+	local $^W = 0;
+	
+	unless( do "./$file" )
+		{
+		print STDERR "_get_prereqs: Error loading $file: $@\n";
+		return;
+		}
+	delete $INC{$file};  # pretend we were never here
+	}
+	
+	my @modules = sort @Test::Prereq::prereqs;
+	@Test::Prereq::prereqs = ();
+	return \@modules;
+	}
+
+# expand prereqs and see what we get
+sub _get_from_prereqs
+	{
+	my $class   = shift;
+	my $modules = shift;
+
+	my @dist_modules = ();
+
+	foreach my $module ( @$modules )
+		{
+		my $mod      = CPAN::Shell->expand( "Module", $module );
+		next unless ref $mod;
+
+		my $distfile = $mod->cpan_file;
+		my $dist     = CPAN::Shell->expand( "Distribution", $distfile );
+
+		my @found    = $dist->containsmods;
+
+		push @dist_modules, @found;
+		}
+
+	return \@dist_modules;
+	}
+
+# get all the loaded modules.  we'll filter this later
+sub _get_loaded_modules
+	{
+	my $class = shift;
+
+#	return unless( defined $_[0] and defined $_[1] );
+#	return unless( -d $_[0] and -d $_[1] );
+
+	my( @libs, @t, @scripts );
+	
+	find( sub { push @libs,    $File::Find::name if m/\.pm$/ }, 'blib/lib' )
+		if -e 'blib/lib';
+	find( sub { push @t,       $File::Find::name if m/\.t$/  }, 't' )
+		if -e 't';
+	find( sub { push @scripts, $File::Find::name if -f $_    }, 'blib/script' )
+		if -e 'blib/script';
+	
+	my @found = ();
+	foreach my $file ( @libs, @t, @scripts )
+		{
+		push @found, @{ $class->_get_from_file( $file ) };
+		}
+
+	return { map { $_, 1 } @found };
+	}
+
+sub _get_test_libraries
+	{
+	my $class = shift;
+
+	my $dirsep = "/";
+
+	my @found = ();
+	
+	find( sub { push @found, $File::Find::name if m/\.p(l|m)$/ }, 't' );
+
+	my @files =
+		map {
+			my $x = $_;
+			$x =~ s/^.*$dirsep//;
+			$x =~ s|$dirsep|::|g;
+			$x;
+			}
+			@found;
+
+	push @files, 'test.pl' if -e 'test.pl';
+
+	return \@files;
+	}
+
+sub _get_dist_modules
+	{
+	my $class = shift;
+
+	return unless( defined $_[0] and -d $_[0] );
+
+	my $dirsep = "/";
+
+	my @found = ();
+	
+	find( sub { push @found, $File::Find::name if m/\.pm$/ }, $_[0] );
+		
+	my @files =
+		map {
+			my $x = $_;
+			$x =~ s/^$_[0]($dirsep)?//;
+			$x =~ s/\.pm$//;
+			$x =~ s|$dirsep|::|g;
+			$x;
+			}
+			@found;
+
+	return \@files;
+	}
+
+sub _get_from_file
+	{
+	my( $class, $file ) = @_;
+
+	my $module  = Module::Info->new_from_file( $file );
+	$module->die_on_compilation_error(1);
+
+	my @used    = eval{ $module->modules_used };
+
+	my @modules =
+		sort
+		grep { not exists $Module::CoreList::version{$version}{$_} }
+		@used;
+
+	@modules = grep { not /$Namespace/ } @modules if $Namespace;
+
+	return \@modules;
+	}
+
+=back
+
+=head1 TO DO
+
+* set up a couple fake module distributions to test
+
+* warn about things that show up in PREREQ_PM unnecessarily
+
+=head1 SOURCE AVAILABILITY
+
+This source is in Github:
+
+	http://github.com/briandfoy/test-prereq
+
+=head1 CONTRIBUTORS
+
+Many thanks to:
+
+Andy Lester, Slavin Rezic, Randal Schwartz, Iain Truskett, Dylan Martin
+
+=head1 AUTHOR
+
+brian d foy, C<< <bdfoy at cpan.org> >>
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright 2002-2009, brian d foy, All rights reserved
+
+This software is available under the same terms as perl.
+
+=cut
+
+1;

Added: branches/upstream/libtest-prereq-perl/current/t/get_from_file.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/get_from_file.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/get_from_file.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/get_from_file.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,26 @@
+# $Id$
+
+use Test::More tests => 2;
+
+use Test::Prereq;
+
+my $modules = Test::Prereq->_get_from_file( 't/pod.t' );
+my @modules = grep ! /^CPANPLUS/, @$modules;
+
+print STDERR "Did not find right modules from t/pod.t!\n" .
+	"Found <@modules>\n" unless
+	ok(
+		eq_array( \@modules, [] ),
+			'Right modules for t/pod.t'
+			);
+
+$modules = Test::Prereq->_get_from_file( 'lib/Prereq.pm' );
+ at modules = grep ! /^CPANPLUS/, @$modules;
+
+print STDERR "Did not find right modules for lib/Prereq.pm!\n" .
+	 "Found <@modules>\n" unless
+		ok(
+			eq_array( \@modules, [ 
+			qw( Module::CoreList Module::Info ) ] ),
+			'Right modules for t/Prereq.pm'
+			);

Added: branches/upstream/libtest-prereq-perl/current/t/get_from_prereqs.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/get_from_prereqs.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/get_from_prereqs.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/get_from_prereqs.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,13 @@
+# $Id$
+use strict;
+
+use Test::Prereq;
+use Test::More tests => 1;
+
+use lib qw(.);
+
+print STDERR "\nThis may take awhile...\n";
+
+my $modules = Test::Prereq->_get_from_prereqs( [ 'Tk' ] );
+
+ok(1);

Added: branches/upstream/libtest-prereq-perl/current/t/get_loaded_modules.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/get_loaded_modules.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/get_loaded_modules.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/get_loaded_modules.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,38 @@
+# $Id$
+
+use Test::More tests => 4;
+
+use Test::Prereq;
+
+{
+my $modules = Test::Prereq->_get_loaded_modules();
+
+my $keys = [ grep ! /^CPANPLUS/, sort keys %$modules ];
+
+print STDERR "Didn't find right modules! Found < @$keys >\n" unless
+ok(
+  eq_array( $keys, 
+		[ 
+		qw( Module::Build Module::CoreList Module::Info 
+			Test::Prereq Test::Prereq::Build) 
+		] ),
+	'Right modules for modules and tests'
+	);
+}
+
+TODO: {
+local $TODO = "This interface changed, so these tests are not valid";
+
+my $modules = Test::Prereq->_get_loaded_modules( );
+my $okay = defined $modules ? 0 : 1;
+ok( $okay, '_get_loaded_modules catches no arguments' );
+
+   $modules = Test::Prereq->_get_loaded_modules( undef, 't' );
+$okay = defined $modules ? 0 : 1;
+ok( $okay, '_get_loaded_modules catches missing first arg' );
+
+   $modules = Test::Prereq->_get_loaded_modules( 'blib/lib', undef );
+$okay = defined $modules ? 0 : 1;
+ok( $okay, '_get_loaded_modules catches missing second arg' );
+
+}

Added: branches/upstream/libtest-prereq-perl/current/t/get_prereqs.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/get_prereqs.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/get_prereqs.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/get_prereqs.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,53 @@
+# $Id$
+use strict;
+BEGIN{ $^W = 0; }
+
+use Test::More tests => 4;
+
+use Cwd;
+use Test::Prereq;
+use Test::Prereq::Build;
+
+
+use lib qw(.);
+
+my $modules = Test::Prereq->_get_prereqs();
+print STDERR "Didn't find right modules!\nFound <@$modules>\n" unless
+ok( eq_array( $modules, 
+		[ 
+		qw( Module::Build Module::CoreList Module::Info 
+		Test::Builder Test::Builder::Tester Test::More ) 
+		] ),
+	'Right modules for Makefile.PL'
+	);
+
+{
+my $cwd = cwd;
+chdir "testdir" or warn "Could not change directory! $!";
+my $modules = Test::Prereq::Build->_get_prereqs();
+
+isa_ok( $modules, 'ARRAY' );
+
+ok(
+  eq_array( $modules, 
+		[ 
+		qw( Config Cwd Data::Dumper File::Basename File::Copy File::Find 
+		File::Path File::Spec ) 
+		] ),
+	'Right modules for Build.PL'
+	);
+
+chdir $cwd or warn "Could not reset dirctory! $!";
+}
+
+{
+my $cwd = cwd;
+chdir "testdir/bad_makefile" or warn "Could not change directory! $!";
+my $modules = Test::Prereq->_get_prereqs();
+
+my $okay = defined $modules ? 0 : 1;
+
+ok( $okay, 'Bad Makefile.PL fails in right way' );
+chdir $cwd or warn "Could not reset dirctory! $!";
+}
+

Added: branches/upstream/libtest-prereq-perl/current/t/import.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/import.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/import.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/import.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,26 @@
+# $Id$
+use strict;
+
+use Test::More tests => 4;
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+package Mimi;
+
+my $value = not defined &prereq_ok;
+main::ok( $value, 'Test::Prereq has not imported yet' );
+
+require Test::Prereq;
+Test::Prereq->import;
+
+main::ok( defined &prereq_ok, 'Test::Prereq imported prereq_ok' );
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+package Buster;
+
+$value = not defined &prereq_ok;
+main::ok( $value, 'Test::Prereq::Build has not imported yet' );
+
+require Test::Prereq::Build;
+Test::Prereq->import;
+
+main::ok( defined &prereq_ok, 'Test::Prereq::Build imported prereq_ok' );

Added: branches/upstream/libtest-prereq-perl/current/t/load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/load.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/load.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/load.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,13 @@
+# $Id$
+BEGIN {
+	@classes = qw(Test::Prereq Test::Prereq::Build);
+	}
+
+use Test::More tests => 2 * scalar @classes;
+
+foreach my $class ( @classes )
+	{
+	undef &main::prereq_ok;
+	print "bail out! Could not compile $class!" unless use_ok( $class );
+	ok( defined &main::prereq_ok, "prereq_ok imported" );
+	}

Added: branches/upstream/libtest-prereq-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/pod.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/pod.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/pod.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,5 @@
+#$Id$
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();

Added: branches/upstream/libtest-prereq-perl/current/t/pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/pod_coverage.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/pod_coverage.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/pod_coverage.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,19 @@
+# $Id$
+
+use Test::More;
+eval "use Test::Pod::Coverage";
+
+if( $@ )
+	{
+	plan skip_all => "Test::Pod::Coverage required for testing POD";
+	}
+else
+	{
+	plan tests => 2;
+
+	pod_coverage_ok( "Test::Prereq" );
+	
+	pod_coverage_ok( "Test::Prereq::Build",
+		{ trustme => [ qr/create_build_script|prereq_ok/ ] } );
+	}
+	

Added: branches/upstream/libtest-prereq-perl/current/t/prereq_ok.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/prereq_ok.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/prereq_ok.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/prereq_ok.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,4 @@
+# $Id$
+
+use Test::Prereq;
+prereq_ok( undef, undef, [ qw(CPANPLUS::Internals::System) ] );

Added: branches/upstream/libtest-prereq-perl/current/t/prior_plan.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/prior_plan.t?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/prior_plan.t (added)
+++ branches/upstream/libtest-prereq-perl/current/t/prior_plan.t Thu Feb 12 03:56:39 2009
@@ -1,0 +1,7 @@
+# $Id$
+
+use Test::More tests => 2;
+
+use Test::Prereq;
+prereq_ok( undef, undef, [ qw(CPANPLUS::Internals::System) ] );
+ok(1);

Added: branches/upstream/libtest-prereq-perl/current/t/test_manifest
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/t/test_manifest?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/t/test_manifest (added)
+++ branches/upstream/libtest-prereq-perl/current/t/test_manifest Thu Feb 12 03:56:39 2009
@@ -1,0 +1,9 @@
+# $Id$
+load.t
+pod.t
+pod_coverage.t
+import.t
+prior_plan.t
+#get_loaded_modules.t
+get_from_prereqs.t
+get_from_file.t

Added: branches/upstream/libtest-prereq-perl/current/testdir/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/testdir/Build.PL?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/testdir/Build.PL (added)
+++ branches/upstream/libtest-prereq-perl/current/testdir/Build.PL Thu Feb 12 03:56:39 2009
@@ -1,0 +1,31 @@
+# $Id$
+# stolen from Module::Build
+
+use lib qw(lib);  # Use Module::Build to test & install itself
+use Module::Build;
+
+my $build = new Module::Build
+  (
+   module_name => 'Module::Build',   
+   license => 'perl',
+   requires => {
+		perl           => '5.6.0',
+		Config         => 0,
+		File::Copy     => 0,
+		File::Find     => 0,
+		File::Path     => 0,
+		File::Basename => 0,
+		File::Spec     => 0,
+		Data::Dumper   => 0,
+		Cwd            => 0,
+	       },
+   recommends => {
+		  YAML => 0.35,
+		  Archive::Tar => 0.22,
+		 },
+   dynamic_config => 1,
+  );
+
+$build->create_build_script;
+
+1;

Added: branches/upstream/libtest-prereq-perl/current/testdir/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/testdir/MANIFEST?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/testdir/MANIFEST (added)
+++ branches/upstream/libtest-prereq-perl/current/testdir/MANIFEST Thu Feb 12 03:56:39 2009
@@ -1,0 +1,1 @@
+this is here to make Module::Build shut up

Added: branches/upstream/libtest-prereq-perl/current/testdir/bad_makefile/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtest-prereq-perl/current/testdir/bad_makefile/Makefile.PL?rev=30601&op=file
==============================================================================
--- branches/upstream/libtest-prereq-perl/current/testdir/bad_makefile/Makefile.PL (added)
+++ branches/upstream/libtest-prereq-perl/current/testdir/bad_makefile/Makefile.PL Thu Feb 12 03:56:39 2009
@@ -1,0 +1,20 @@
+# $Id$
+use ExtUtils::MakeMaker;
+
+WriteMakefile
+        (
+        'NAME'      => 'Test::Prereq',
+        'VERSION'   => '0.05',
+ 		'PREREQ_PM' => {
+ 			'HTTP::Size'      => 0,
+  			},
+        'PM'        => 
+        	{
+            'lib/Prereq.pm' => '$(INST_LIBDIR)/Prereq.pm',
+            },
+ 
+		depend => { Makefile => 't/test_manifest' },
+        test   => { TESTS => $tests },
+        );
+
+0;




More information about the Pkg-perl-cvs-commits mailing list