Skip to content

Commit

Permalink
Merge pull request #7 from wu-lee/wu-lee/test-prereqs-build
Browse files Browse the repository at this point in the history
Module/Release/Prereq.pm - use Test::Prereq::Build when appropriate
  • Loading branch information
briandfoy committed Apr 17, 2017
2 parents 094f879 + cb102c5 commit 05e676f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/Module/Release.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ The name of the file to run as F<Makefile.PL>. The default is
C<"Makefile.PL">, but you can set it to C<"Build.PL"> to use a
C<Module::Build>-based system.
If this is set to C<"Build.PL">, this his will also cause
C<Module::Build::Prereqs> to use C<Test::Prereqs::Build> instead of
C<Test::Prereqs>.
=item makefile
The name of the file created by C<makefile_PL> above. The default is
Expand Down
18 changes: 14 additions & 4 deletions lib/Module/Release/Prereq.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,29 @@ It looks in local_name to get the name of the distribution file.
=cut


my %Prereq_modules = (
'' => 'Test::Prereq',
'Makefile.PL' => 'Test::Prereq',
'Build.PL' => 'Test::Prereq::Build',
);

sub check_prereqs
{
eval "require Test::Prereq; 1 " or
$_[0]->_die( "You need Test::Prereq to check prereqs" );
my $prereqs_type = $_[0]->config->makefile_PL;
my $test_prereqs = $Prereq_modules{$prereqs_type} || 'Test::Prereq';

eval "require $test_prereqs; 1 " or
$_[0]->_die( "You need $test_prereqs to check prereqs" );

$_[0]->_print( "Checking prereqs... " );
$_[0]->_print( "Checking prereqs with $test_prereqs... " );

my $perl = $_[0]->{perl};

my @ignore = $_[0]->_get_prereq_ignore_list;

my $messages = $_[0]->run(
qq|$perl -MTest::Prereq -e "prereq_ok( undef, undef, [ qw(@ignore) ] )"|
qq|$perl -M$test_prereqs -e "prereq_ok( undef, undef, [ qw(@ignore) ] )"|
);

$_[0]->_die( "Prereqs had a problem:\n$messages\n" )
Expand Down

0 comments on commit 05e676f

Please sign in to comment.