lib/ExtUtils/t/maketext_filter.t See if maketext_filter works
lib/ExtUtils/t/metafile_data.t See if META.yml handling works
lib/ExtUtils/t/metafile_file.t See if META.yml handling works
+lib/ExtUtils/t/min_perl_version.t Test the MIN_PERL_VERSION argument to WriteMakefile.
lib/ExtUtils/t/Manifest.t See if ExtUtils::Manifest works
lib/ExtUtils/t/Mkbootstrap.t See if ExtUtils::Mkbootstrap works
lib/ExtUtils/t/MM_Any.t See if ExtUtils::MM_Any works
t/lib/locale/latin1 Part of locale.t in Latin 1
t/lib/locale/utf8 Part of locale.t in UTF8
t/lib/MakeMaker/Test/Setup/BFD.pm MakeMaker test utilities
+t/lib/MakeMaker/Test/Setup/MPV.pm MakeMaker test utilities
t/lib/MakeMaker/Test/Setup/PL_FILES.pm MakeMaker test utilities
t/lib/MakeMaker/Test/Setup/Problem.pm MakeMaker test utilities
t/lib/MakeMaker/Test/Setup/Recurs.pm MakeMaker test utilities
our @EXPORT = qw(test_harness pod2man perllocal_install uninstall
warn_if_old_packlist);
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
my $Is_VMS = $^O eq 'VMS';
use strict;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
use File::Spec;
require ExtUtils::Liblist::Kid;
# Broken out of MakeMaker from version 4.11
use strict;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
use Config;
use Cwd 'cwd';
use strict;
use ExtUtils::MakeMaker::Config;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::Liblist;
require ExtUtils::MakeMaker;
package ExtUtils::MM_AIX;
use strict;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::MM_Unix;
our @ISA = qw(ExtUtils::MM_Unix);
package ExtUtils::MM_Any;
use strict;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
use Carp;
use File::Spec;
version => 1.4
},
);
+
+ # The author key is required and it takes a list.
$meta{author} = defined $self->{AUTHOR} ? [$self->{AUTHOR}] : [];
+
$meta{requires} = $self->{PREREQ_PM} if defined $self->{PREREQ_PM};
+ $meta{requires}{perl} = $self->{MIN_PERL_VERSION} if $self->{MIN_PERL_VERSION};
while( my($key, $val) = each %$meta_add ) {
$meta{$key} = $val;
require ExtUtils::MM_Unix;
our @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
=item os_flavor
require ExtUtils::MM_Unix;
our @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
=head1 NAME
use strict;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
require ExtUtils::MM_Any;
require ExtUtils::MM_Unix;
use strict;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
sub new {
die <<'UNSUPPORTED';
use ExtUtils::MakeMaker::Config;
use File::Basename;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::MM_Win32;
our @ISA = qw(ExtUtils::MM_Win32);
use ExtUtils::MakeMaker qw(neatvalue);
use File::Spec;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::MM_Any;
require ExtUtils::MM_Unix;
package ExtUtils::MM_QNX;
use strict;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::MM_Unix;
our @ISA = qw(ExtUtils::MM_Unix);
package ExtUtils::MM_UWIN;
use strict;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
require ExtUtils::MM_Unix;
our @ISA = qw(ExtUtils::MM_Unix);
# If we make $VERSION an our variable parse_version() breaks
use vars qw($VERSION);
-$VERSION = '6.46_01';
+$VERSION = '6.47_01';
require ExtUtils::MM_Any;
our @ISA = qw(ExtUtils::MM_Any);
}
else {
$self->{ABSPERL} = $self->rel2abs($self->{ABSPERL});
+
+ # Quote the perl command if it contains whitespace
+ $self->{ABSPERL} = $self->quote_literal($self->{ABSPERL})
+ if $self->{ABSPERL} =~ /\s/;
+
$self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
}
- $self->{ABSPERL} = qq{"$self->{ABSPERL}"}
- if ($self->{ABSPERL} =~ /\s/) && ! $has_mcr;
-
# Are we building the core?
$self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
$self->{PERL_CORE} = 0 unless defined $self->{PERL_CORE};
"";
}
+# transform dot-separated version string into comma-separated quadruple
+# examples: '1.2.3.4.5' => '1,2,3,4'
+# '1.2.3' => '1,2,3,0'
+sub _ppd_version {
+ my ($self, $string) = @_;
+ return join ',', ((split /\./, $string), (0) x 4)[0..3];
+}
+
=item ppd
Defines target that creates a PPD (Perl Package Description) file
sub ppd {
my($self) = @_;
- my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
+ my $pack_ver = $self->_ppd_version($self->{VERSION});
my $abstract = $self->{ABSTRACT} || '';
$abstract =~ s/\n/\\n/sg;
PPD_HTML
$ppd_xml .= " <IMPLEMENTATION>\n";
+ if ( $self->{MIN_PERL_VERSION} ) {
+ my $min_perl_version = $self->_ppd_version($self->{MIN_PERL_VERSION});
+ $ppd_xml .= sprintf <<'PPD_PERLVERS', $min_perl_version;
+ <PERLCORE VERSION="%s" />
+PPD_PERLVERS
+
+ }
foreach my $prereq (sort keys %{$self->{PREREQ_PM}}) {
my $pre_req = $prereq;
$pre_req =~ s/::/-/g;
- my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}),
- (0) x 4) [0 .. 3];
+ my $dep_ver = $self->_ppd_version($self->{PREREQ_PM}{$prereq});
$ppd_xml .= sprintf <<'PPD_OUT', $pre_req, $dep_ver;
<DEPENDENCY NAME="%s" VERSION="%s" />
PPD_OUT
use File::Basename;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::MM_Any;
require ExtUtils::MM_Unix;
package ExtUtils::MM_VOS;
use strict;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::MM_Unix;
our @ISA = qw(ExtUtils::MM_Unix);
require ExtUtils::MM_Any;
require ExtUtils::MM_Unix;
our @ISA = qw( ExtUtils::MM_Any ExtUtils::MM_Unix );
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
$ENV{EMXSHELL} = 'sh'; # to run `commands`
sub init_DIRFILESEP {
my($self) = shift;
- my $make = $self->make;
-
# The ^ makes sure its not interpreted as an escape in nmake
$self->{DIRFILESEP} = $self->is_make_type('nmake') ? '^\\' :
$self->is_make_type('dmake') ? '\\\\'
use strict;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require ExtUtils::MM_Win32;
our @ISA = qw(ExtUtils::MM_Win32);
use strict;
require ExtUtils::MM;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
our @ISA = qw(ExtUtils::MM);
{
-# $Id: /local/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm 66493 2008-09-27T21:35:25.560547Z schwern $
+# $Id$
package ExtUtils::MakeMaker;
use strict;
my @Prepend_parent;
my %Recognized_Att_Keys;
-our $VERSION = '6.46';
-our ($Revision) = q$Revision: 66493 $ =~ /Revision:\s+(\S+)/;
+our $VERSION = '6.47_01';
+
+# Emulate something resembling CVS $Revision$
+(our $Revision = $VERSION) =~ s{_}{};
+$Revision = int $Revision * 10000;
+
our $Filename = __FILE__; # referenced outside MakeMaker
our @ISA = qw(Exporter);
INC INCLUDE_EXT LDFROM LIB LIBPERL_A LIBS LICENSE
LINKTYPE MAKE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET
- META_ADD META_MERGE
+ META_ADD META_MERGE MIN_PERL_VERSION
MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NORECURS NO_VC OBJECT OPTIMIZE
PERL_MALLOC_OK PERL PERLMAINCC PERLRUN PERLRUNINST PERL_CORE
PERL_SRC PERM_RW PERM_RWX
if ("@ARGV" =~ /\bPREREQ_PRINT\b/) {
require Data::Dumper;
- print Data::Dumper->Dump([$self->{PREREQ_PM}], [qw(PREREQ_PM)]);
+ my @what = ('PREREQ_PM');
+ push @what, 'MIN_PERL_VERSION' if $self->{MIN_PERL_VERSION};
+ print Data::Dumper->Dump([@{$self}{@what}], \@what);
exit 0;
}
# PRINT_PREREQ is RedHatism.
if ("@ARGV" =~ /\bPRINT_PREREQ\b/) {
- print join(" ", map { "perl($_)>=$self->{PREREQ_PM}->{$_} " }
- sort keys %{$self->{PREREQ_PM}}), "\n";
+ my @prereq =
+ map { [$_, $self->{PREREQ_PM}{$_}] } keys %{$self->{PREREQ_PM}};
+ if ( $self->{MIN_PERL_VERSION} ) {
+ push @prereq, ['perl' => $self->{MIN_PERL_VERSION}];
+ }
+
+ print join(" ", map { "perl($_->[0])>=$_->[1] " }
+ sort { $a->[0] cmp $b->[0] } @prereq), "\n";
exit 0;
}
check_hints($self);
+ # Translate X.Y.Z to X.00Y00Z
+ if( defined $self->{MIN_PERL_VERSION} ) {
+ $self->{MIN_PERL_VERSION} =~ s{ ^ (\d+) \. (\d+) \. (\d+) $ }
+ {sprintf "%d.%03d%03d", $1, $2, $3}ex;
+ }
+
+ my $perl_version_ok = eval {
+ local $SIG{__WARN__} = sub {
+ # simulate "use warnings FATAL => 'all'" for vintage perls
+ die @_;
+ };
+ !$self->{MIN_PERL_VERSION} or $self->{MIN_PERL_VERSION} <= $]
+ };
+ if (!$perl_version_ok) {
+ if (!defined $perl_version_ok) {
+ warn <<'END';
+Warning: MIN_PERL_VERSION is not in a recognized format.
+Recommended is a quoted numerical value like '5.005' or '5.008001'.
+END
+ }
+ elsif ($self->{PREREQ_FATAL}) {
+ die sprintf <<"END", $self->{MIN_PERL_VERSION}, $];
+MakeMaker FATAL: perl version too low for this distribution.
+Required is %s. We run %s.
+END
+ }
+ else {
+ warn sprintf
+ "Warning: Perl version %s or higher required. We run %s.\n",
+ $self->{MIN_PERL_VERSION}, $];
+ }
+ }
+
my %configure_att; # record &{$self->{CONFIGURE}} attributes
my(%initial_att) = %$self; # record initial attributes
Unless you want to override the defaults, prefer META_MERGE so as to
get the advantage of any future defaults.
+=item MIN_PERL_VERSION
+
+The minimum required version of Perl for this distribution.
+
+Either 5.006001 or 5.6.1 format is acceptable.
+
=item MYEXTLIB
If the extension links to a library that it builds set this to the
stdout and MakeMaker will exit. The output format is an evalable hash
ref.
-$PREREQ_PM = {
- 'A::B' => Vers1,
- 'C::D' => Vers2,
- ...
- };
+ $PREREQ_PM = {
+ 'A::B' => Vers1,
+ 'C::D' => Vers2,
+ ...
+ };
+
+If a distribution defines a minimal required perl version, this is
+added to the output as an additional line of the form:
+
+ $MIN_PERL_VERSION = '5.008001';
=item PRINT_PREREQ
perl(A::B)>=Vers1 perl(C::D)>=Vers2 ...
+A minimal required perl version, if present, will look like this:
+
+ perl(perl)>=5.008001
+
=item SITEPREFIX
Like PERLPREFIX, but only for the site install locations.
$VERSION = '1.00';
*VERSION = \'1.01';
- ($VERSION) = q$Revision: 66493 $ =~ /(\d+)/g;
+ ($VERSION) = q$Revision$ =~ /(\d+)/g;
$FOO::VERSION = '1.10';
*FOO::VERSION = \'1.11';
use strict;
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
use Config ();
use strict;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
my $Have_Bytes = eval { require bytes; 1; };
use strict;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
my $IsVMS = $^O eq 'VMS';
# There's just too much Dynaloader incest here to turn on strict vars.
use strict 'refs';
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
require Exporter;
our @ISA = ('Exporter');
our @ISA = qw(Exporter);
our @EXPORT = qw(&Mksymlists);
-our $VERSION = '6.46';
+our $VERSION = '6.47_01';
sub Mksymlists {
my(%spec) = @_;
open(FILE, ">command"); print FILE "foo"; close FILE;
SKIP: {
-skip ("no separate execute mode", 1) if ($^O eq "vos");
-ok (!$t->maybe_command('command') ,"non executable file isn't a command");
-}
+ skip("no separate execute mode on VOS", 2) if $^O eq "vos";
+
+ ok !$t->maybe_command('command') ,"non executable file isn't a command";
-chmod 0755, "command";
-ok ($t->maybe_command('command'), "executable file is a command");
+ chmod 0755, "command";
+ ok ($t->maybe_command('command'), "executable file is a command");
+}
unlink "command";
use Test::More tests => 4;
-my @cd_args = ("some/dir", "command1", "command2");
+my $dir = File::Spec->catdir("some", "dir");
+my @cd_args = ($dir, "command1", "command2");
{
package Test::MM_Win32;
my $expected_updir = File::Spec->catdir(@dirs);
::is $mm->cd(@cd_args),
-qq{cd some/dir
+qq{cd $dir
command1
command2
cd $expected_updir};
local *make = sub { "dmake" };
::is $mm->cd(@cd_args),
-q{cd some/dir && command1
- cd some/dir && command2};
+qq{cd $dir && command1
+ cd $dir && command2};
}
}
{
is +ExtUtils::MM_Unix->cd(@cd_args),
-q{cd some/dir && command1
- cd some/dir && command2};
+qq{cd $dir && command1
+ cd $dir && command2};
}
SKIP: {
}
use strict;
-use Test::More tests => 3;
+use Test::More tests => 5;
use Data::Dumper;
wobble => 42,
];
}
+
+
+# Test MIN_PERL_VERSION
+{
+ my $mm = $new_mm->(
+ DISTNAME => 'Foo-Bar',
+ VERSION => 1.23,
+ PM => {
+ "Foo::Bar" => 'lib/Foo/Bar.pm',
+ },
+ MIN_PERL_VERSION => 5.006,
+ );
+
+ is_deeply [$mm->metafile_data], [
+ name => 'Foo-Bar',
+ version => 1.23,
+ abstract => undef,
+ author => [],
+ license => 'unknown',
+ distribution_type => 'module',
+
+ configure_requires => {
+ 'ExtUtils::MakeMaker' => 0,
+ },
+
+ requires => {
+ perl => '5.006',
+ },
+
+ 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
+ },
+ ];
+}
+
+
+# Test MIN_PERL_VERSION
+{
+ my $mm = $new_mm->(
+ DISTNAME => 'Foo-Bar',
+ VERSION => 1.23,
+ PM => {
+ "Foo::Bar" => 'lib/Foo/Bar.pm',
+ },
+ MIN_PERL_VERSION => 5.006,
+ PREREQ_PM => {
+ 'Foo::Bar' => 1.23,
+ },
+ );
+
+ is_deeply [$mm->metafile_data], [
+ name => 'Foo-Bar',
+ version => 1.23,
+ abstract => undef,
+ author => [],
+ license => 'unknown',
+ distribution_type => 'module',
+
+ configure_requires => {
+ 'ExtUtils::MakeMaker' => 0,
+ },
+
+ requires => {
+ perl => '5.006',
+ 'Foo::Bar' => 1.23,
+ },
+
+ 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
+ },
+ ];
+}
}
use strict;
-use Test::More tests => 13;
+use Test::More tests => 16;
require ExtUtils::MM_Any;
YAML
is($mm->metafile_file(@meta), $expected, "META.yml with extra 'no_index' works");
+
+
+ # Make sure YAML.pm can ready our output
+ SKIP: {
+ skip "Need YAML.pm to test if it can load META.yml", 1
+ unless eval { require YAML };
+
+ my $yaml_load = YAML::Load($mm->metafile_file(@meta));
+ is_deeply( $yaml_load, {@meta}, "META.yml can be read by YAML.pm" );
+ }
+
+
+ SKIP: {
+ skip "Need YAML::Tiny to test if it can load META.yml", 2
+ unless eval { require YAML::Tiny };
+
+ my @yaml_load = YAML::Tiny::Load($mm->metafile_file(@meta));
+ is @yaml_load, 1, "YAML::Tiny saw one document in META.yml";
+ is_deeply( $yaml_load[0], {@meta}, "META.yml can be read by YAML::Tiny" );
+ }
}
+
{
my @meta = ( k => 'a : b', 'x : y' => 1 );
my $expected = <<YAML;
--- /dev/null
+#!/usr/bin/perl -w
+
+# This is a test checking various aspects of the optional argument
+# MIN_PERL_VERSION to WriteMakefile.
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't' if -d 't';
+ @INC = ('../lib', 'lib');
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use Test::More tests => 33;
+
+use TieOut;
+use MakeMaker::Test::Utils;
+use MakeMaker::Test::Setup::MPV;
+use File::Path;
+
+use ExtUtils::MakeMaker;
+
+# avoid environment variables interfering with our make runs
+delete @ENV{qw(LIB MAKEFLAGS)};
+
+my $perl = which_perl();
+my $make = make_run();
+my $makefile = makefile_name();
+
+chdir 't';
+
+perl_lib();
+
+ok( setup_recurs(), 'setup' );
+END {
+ ok( chdir(File::Spec->updir), 'leaving dir' );
+ ok( teardown_recurs(), 'teardown' );
+}
+
+ok( chdir 'Min-PerlVers', 'entering dir Min-PerlVers' ) ||
+ diag("chdir failed: $!");
+
+{
+ # ----- argument verification -----
+
+ my $stdout = tie *STDOUT, 'TieOut';
+ ok( $stdout, 'capturing stdout' );
+ my $warnings = '';
+ local $SIG{__WARN__} = sub {
+ $warnings .= join '', @_;
+ };
+
+ eval {
+ WriteMakefile(
+ NAME => 'Min::PerlVers',
+ MIN_PERL_VERSION => '5',
+ );
+ };
+ is( $warnings, '', 'MIN_PERL_VERSION=5 does not trigger a warning' );
+ is( $@, '', ' nor a hard failure' );
+
+
+ $warnings = '';
+ eval {
+ WriteMakefile(
+ NAME => 'Min::PerlVers',
+ MIN_PERL_VERSION => '5.4.4',
+ );
+ };
+ is( $warnings, '', 'MIN_PERL_VERSION=X.Y.Z does not trigger a warning' );
+ is( $@, '', ' nor a hard failure' );
+
+
+ $warnings = '';
+ eval {
+ WriteMakefile(
+ NAME => 'Min::PerlVers',
+ MIN_PERL_VERSION => '999999',
+ );
+ };
+ ok( '' ne $warnings, 'MIN_PERL_VERSION=999999 triggers a warning' );
+ is( $warnings,
+ "Warning: Perl version 999999 or higher required. We run $].\n",
+ ' with expected message text' );
+ is( $@, '', ' and without a hard failure' );
+
+ $warnings = '';
+ eval {
+ WriteMakefile(
+ NAME => 'Min::PerlVers',
+ MIN_PERL_VERSION => '999999',
+ PREREQ_FATAL => 1,
+ );
+ };
+ is( $warnings, '', 'MIN_PERL_VERSION=999999 and PREREQ_FATAL: no warning' );
+ is( $@, <<"END", ' correct exception' );
+MakeMaker FATAL: perl version too low for this distribution.
+Required is 999999. We run $].
+END
+
+ $warnings = '';
+ eval {
+ WriteMakefile(
+ NAME => 'Min::PerlVers',
+ MIN_PERL_VERSION => 'foobar',
+ );
+ };
+ ok( '' ne $warnings, 'MIN_PERL_VERSION=foobar triggers a warning' );
+ is( $warnings, <<'END', ' with expected message text' );
+Warning: MIN_PERL_VERSION is not in a recognized format.
+Recommended is a quoted numerical value like '5.005' or '5.008001'.
+END
+
+ is( $@, '', ' and without a hard failure' );
+}
+
+
+# ----- PREREQ_PRINT output -----
+{
+ my $prereq_out = run(qq{$perl Makefile.PL "PREREQ_PRINT=1"});
+ is( $?, 0, 'PREREQ_PRINT exiting normally' );
+ my $prereq_out_sane = $prereq_out =~ /^\s*\$PREREQ_PM\s*=/;
+ ok( $prereq_out_sane, ' and talking like we expect' ) ||
+ diag($prereq_out);
+
+ SKIP: {
+ 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);
+ $ERR = '';
+ eval {
+ eval $prereq_out; ## no critic
+ $ERR = $@;
+ };
+ ::is( $@ . $ERR, '', 'prereqs evaluable' );
+ ::is_deeply( $PREREQ_PM, { strict => 0 }, ' and looking correct' );
+ ::is( $MIN_PERL_VERSION, '5.005', 'min version also correct' );
+ }
+}
+
+
+# ----- PRINT_PREREQ output -----
+{
+ my $prereq_out = run(qq{$perl Makefile.PL "PRINT_PREREQ=1"});
+ is( $?, 0, 'PRINT_PREREQ exiting normally' );
+ ok( $prereq_out !~ /^warning/i, ' and not complaining loudly' );
+ like( $prereq_out,
+ qr/^perl\(perl\) \s* >= 5\.005 \s+ perl\(strict\) \s* >= \s* 0 \s*$/x,
+ 'dump has prereqs and perl version' );
+}
+
+
+# ----- generated files verification -----
+{
+ unlink $makefile;
+ my @mpl_out = run(qq{$perl Makefile.PL});
+ END { unlink $makefile, makefile_backup() }
+
+ cmp_ok( $?, '==', 0, 'Makefile.PL exiting normally' ) || diag(@mpl_out);
+ ok( -e $makefile, 'Makefile present' );
+}
+
+
+# ----- ppd output -----
+{
+ my $ppd_file = 'Min-PerlVers.ppd';
+ my @make_out = run(qq{$make ppd});
+ END { unlink $ppd_file }
+
+ cmp_ok( $?, '==', 0, 'Make ppd exiting normally' ) || diag(@make_out);
+
+ my $ppd_html = slurp($ppd_file);
+ ok( defined($ppd_html), ' .ppd file present' );
+
+ like( $ppd_html, qr{^\s*<PERLCORE VERSION="5,005,0,0" />}m,
+ ' .ppd file content good' );
+}
+
+
+# ----- META.yml output -----
+{
+ my $distdir = 'Min-PerlVers-0.05';
+ my $meta_yml = "$distdir/META.yml";
+ my @make_out = run(qq{$make metafile});
+ END { rmtree $distdir }
+
+ cmp_ok( $?, '==', 0, 'Make metafile exiting normally' ) || diag(@make_out);
+ my $meta = slurp($meta_yml);
+ ok( defined($meta), ' META.yml present' );
+
+ like( $meta, qr{\nrequires:[^\S\n]*\n\s+perl:\s+5\.005\n\s+strict:\s+0\n},
+ ' META.yml content good');
+}
+
+__END__
use strict;
use warnings;
-our $VERSION = 6.46;
+our $VERSION = 6.47_01;
use Cwd;
use File::Spec;
--- /dev/null
+package MakeMaker::Test::Setup::MPV;
+
+@ISA = qw(Exporter);
+require Exporter;
+@EXPORT = qw(setup_recurs teardown_recurs);
+
+use strict;
+use File::Path;
+use File::Basename;
+
+my %Files = (
+ 'Min-PerlVers/Makefile.PL' => <<'END',
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Min::PerlVers',
+ AUTHOR => 'John Doe <jd@example.com>',
+ VERSION_FROM => 'lib/Min/PerlVers.pm',
+ PREREQ_PM => { strict => 0 },
+ MIN_PERL_VERSION => '5.005',
+);
+END
+
+ 'Min-PerlVers/lib/Min/PerlVers.pm' => <<'END',
+package Min::PerlVers;
+
+$VERSION = 0.05;
+
+=head1 NAME
+
+Min::PerlVers - being picky about perl versions
+
+=cut
+
+1;
+END
+
+);
+
+
+sub setup_recurs {
+ while(my($file, $text) = each %Files) {
+ # Convert to a relative, native file path.
+ $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file);
+
+ my $dir = dirname($file);
+ mkpath $dir;
+ open(FILE, ">$file") || die "Can't create $file: $!";
+ print FILE $text;
+ close FILE;
+ }
+
+ return 1;
+}
+
+sub teardown_recurs {
+ foreach my $file (keys %Files) {
+ my $dir = dirname($file);
+ if( -e $dir ) {
+ rmtree($dir) || return;
+ }
+ }
+ return 1;
+}
+
+
+1;
require Exporter;
@ISA = qw(Exporter);
-$VERSION = 0.03;
+$VERSION = 0.04;
@EXPORT = qw(which_perl perl_lib makefile_name makefile_backup
make make_run run make_macro calibrate_mtime
setup_mm_test_root
- have_compiler
+ have_compiler slurp
);
my $Is_VMS = $^O eq 'VMS';
my $have_compiler = have_compiler();
+ my $text = slurp($filename);
+
=head1 DESCRIPTION
return $have_compiler;
}
+=item slurp
+
+ $text = slurp($filename);
+
+Returns the contents of a file if it can be read, otherwise undef.
+Contents of excessively large files are truncated to a couple of
+kilobytes, though.
+
+=cut
+
+sub slurp {
+ my $filename = shift;
+ my $text = undef;
+ local *FH;
+ local $/ = \8192;
+ if (open FH, $filename) {
+ $text = <FH>;
+ close FH;
+ }
+ return $text;
+}
=back