summaryrefslogtreecommitdiff
path: root/lib/ExtUtils/t
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2009-07-16 10:53:04 +0100
committerDavid Mitchell <davem@iabyn.com>2009-07-16 10:53:04 +0100
commitb6d6132c1554383190492215dd1da143d1d564ef (patch)
tree0443a528c7d6efb2564fa76f5287c37aaeda0247 /lib/ExtUtils/t
parentd9ac7b6b660cff1409a0aa305d95403874c8725a (diff)
downloadperl-b6d6132c1554383190492215dd1da143d1d564ef.tar.gz
ExtUtils::MakeMaker 6.55_01
Diffstat (limited to 'lib/ExtUtils/t')
-rw-r--r--lib/ExtUtils/t/MakeMaker_Parameters.t74
-rw-r--r--lib/ExtUtils/t/metafile_data.t44
-rw-r--r--lib/ExtUtils/t/min_perl_version.t2
3 files changed, 117 insertions, 3 deletions
diff --git a/lib/ExtUtils/t/MakeMaker_Parameters.t b/lib/ExtUtils/t/MakeMaker_Parameters.t
new file mode 100644
index 0000000000..734a1bc245
--- /dev/null
+++ b/lib/ExtUtils/t/MakeMaker_Parameters.t
@@ -0,0 +1,74 @@
+#!/usr/bin/perl -w
+
+# Things like the CPAN shell rely on the "MakeMaker Parameters" section of the
+# Makefile to learn a module's dependencies so we'd damn well better test it.
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't' if -d 't';
+ @INC = ('../lib', 'lib');
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+
+use ExtUtils::MakeMaker;
+use Test::More;
+
+my $mm = bless {}, "MM";
+
+sub extract_params {
+ my $text = join "\n", @_;
+
+ $text =~ s{^\s* \# \s+ MakeMaker\ Parameters: \s*\n}{}x;
+ $text =~ s{^#}{}gms;
+ $text =~ s{\n}{,\n}g;
+
+ no strict 'subs';
+ return { eval "$text" };
+}
+
+sub test_round_trip {
+ my $args = shift;
+ my $want = @_ ? shift : $args;
+
+ my $have = extract_params($mm->_MakeMaker_Parameters_section($args));
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ is_deeply $have, $want or diag explain $have, "\n", $want;
+}
+
+is join("", $mm->_MakeMaker_Parameters_section()), <<'EXPECT', "nothing";
+ # MakeMaker Parameters:
+EXPECT
+
+test_round_trip({ NAME => "Foo" });
+test_round_trip({ NAME => "Foo", PREREQ_PM => { "Foo::Bar" => 0 } });
+test_round_trip({ NAME => "Foo", PREREQ_PM => { "Foo::Bar" => 1.23 } });
+
+# Test the special case for BUILD_REQUIRES
+{
+ my $have = {
+ NAME => "Foo",
+ PREREQ_PM => { "Foo::Bar" => 1.23 },
+ BUILD_REQUIRES => { "Baz" => 0.12 },
+ };
+
+ my $want = {
+ NAME => "Foo",
+ PREREQ_PM => {
+ "Foo::Bar" => 1.23,
+ "Baz" => 0.12,
+ },
+ BUILD_REQUIRES => { "Baz" => 0.12 },
+ };
+
+ test_round_trip( $have, $want );
+}
+
+done_testing();
+
diff --git a/lib/ExtUtils/t/metafile_data.t b/lib/ExtUtils/t/metafile_data.t
index ddb986b2c6..29d271cfce 100644
--- a/lib/ExtUtils/t/metafile_data.t
+++ b/lib/ExtUtils/t/metafile_data.t
@@ -9,14 +9,14 @@ BEGIN {
}
use strict;
-use Test::More tests => 6;
+use Test::More tests => 7;
use Data::Dumper;
require ExtUtils::MM_Any;
my $new_mm = sub {
- return bless {@_}, 'ExtUtils::MM_Any';
+ return bless { ARGS => {@_}, @_ }, 'ExtUtils::MM_Any';
};
{
@@ -273,3 +273,43 @@ my $new_mm = sub {
},
],'CONFIGURE_REQUIRES';
}
+
+# Test BUILD_REQUIRES
+{
+ my $mm = $new_mm->(
+ DISTNAME => 'Foo-Bar',
+ VERSION => 1.23,
+ BUILD_REQUIRES => {
+ "Fake::Module1" => 1.01,
+ },
+ PM => {
+ "Foo::Bar" => 'lib/Foo/Bar.pm',
+ },
+ );
+
+ is_deeply [$mm->metafile_data], [
+ name => 'Foo-Bar',
+ version => 1.23,
+ abstract => undef,
+ author => [],
+ license => 'unknown',
+ distribution_type => 'module',
+
+ configure_requires => {
+ 'ExtUtils::MakeMaker' => 0,
+ },
+ build_requires => {
+ 'Fake::Module1' => 1.01,
+ },
+
+ no_index => {
+ directory => [qw(t inc)],
+ },
+
+ generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
+ 'meta-spec' => {
+ url => 'http://module-build.sourceforge.net/META-spec-v1.4.html',
+ version => 1.4
+ },
+ ],'CONFIGURE_REQUIRES';
+}
diff --git a/lib/ExtUtils/t/min_perl_version.t b/lib/ExtUtils/t/min_perl_version.t
index 7e44570b0f..9dc6088bf3 100644
--- a/lib/ExtUtils/t/min_perl_version.t
+++ b/lib/ExtUtils/t/min_perl_version.t
@@ -130,7 +130,7 @@ END
skip 'not going to evaluate rubbish', 3 if !$prereq_out_sane;
package _Prereq::Print::WithMPV; ## no critic
- use vars qw($PREREQ_PM $MIN_PERL_VERSION $ERR);
+ our($PREREQ_PM, $BUILD_REQUIRES, $MIN_PERL_VERSION, $ERR);
$ERR = '';
eval {
eval $prereq_out; ## no critic