X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Makefile.PL;h=004ea1c722a5ca4bdee57c7ea3ccab481505e433;hb=c1809cb18c9ffb1f6fbb152bf546aca88647172b;hp=d94015d15f6a1f0b3bb5c0d813b7bde01350fd27;hpb=e896822dbc5d27f54b7336d2b46df47b8027b3c2;p=gitmo%2FClass-MOP.git diff --git a/Makefile.PL b/Makefile.PL index d94015d..004ea1c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -7,6 +7,8 @@ use ExtUtils::MakeMaker; use Config qw(%Config); use File::Spec; +use 5.008; + # If undefined, try our best, if true, require XS, if false, never do # XS my $force_xs; @@ -23,16 +25,26 @@ unless ( defined $force_xs ) { } my %prereqs = ( - 'Scalar::Util' => '1.18', - 'Sub::Name' => '0.02', - 'Sub::Identify' => '0.03', - 'MRO::Compat' => '0.05', - 'Carp' => 0, + 'Scalar::Util' => '1.18', + 'Sub::Name' => '0.04', + 'Sub::Identify' => '0.03', + 'MRO::Compat' => '0.05', + 'Test::More' => '0', + 'Test::Exception' => '0', + 'File::Spec' => '0', + 'Carp' => '0', + 'Devel::GlobalDestruction' => '0', + 'Task::Weaken' => '0', + 'B' => '0', ); -delete $prereqs{'Sub::Name'} +delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)} unless $has_compiler; +if ($has_compiler && is_maintainer()) { + create_pp_tests(); +} + write_makefile(); sub write_makefile { @@ -44,7 +56,7 @@ sub write_makefile { PREREQ_PM => \%prereqs, CONFIGURE => \&init, CCFLAGS => $ccflags, - clean => { FILES => 'test.c test.o' }, + clean => { FILES => 'test.c test.o t/pp*' }, ABSTRACT_FROM => 'lib/Class/MOP.pm', AUTHOR => 'Stevan Little ', LICENSE => 'perl', @@ -110,6 +122,43 @@ EOF return 1; } +# This sucks, but it's the best guess we can make. Since we just use +# it to run two sets of tests, it's not big deal if it ends up true +# for a non-maintainer. +sub is_maintainer { + return 0 if $ENV{PERL5_CPAN_IS_RUNNING} || $ENV{PERL5_CPANPLUS_IS_RUNNING}; + + return 1; +} + +sub create_pp_tests { + opendir my $dh, 't' or die "Cannot read t: $!"; + + foreach my $file ( grep {/^\d.+\.t$/} readdir $dh ) { + next if $file =~ /^99/; + + my $real_file = File::Spec->catfile( 't', $file ); + + open my $fh, '<', $real_file + or die "Cannot read $real_file: $!"; + + my $shbang = <$fh>; + my $test = do { local $/; <$fh> }; + + close $fh; + + $test = "$shbang\nBEGIN { \$ENV{CLASS_MOP_NO_XS} = 1 }\n\n$test"; + + my $new_file = File::Spec->catfile( 't', "pp_$file" ); + open my $new_fh, '>', $new_file + or die "Cannot write to $new_file: $!"; + + print $new_fh $test; + + close $new_fh; + } +} + # This is EUMM voodoo sub init { my $hash = $_[1];