Disable deprecated get_all_packge_symbols in list context.
[gitmo/Class-MOP.git] / Makefile.PL
index e0793f1..7cfceca 100644 (file)
@@ -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;
@@ -16,20 +18,24 @@ for (@ARGV) {
     /^--xs/ and $force_xs = 1;
 }
 
-my $has_compiler = $force_xs;
+our $has_compiler = $force_xs;
 unless ( defined $force_xs ) {
     $has_compiler = check_for_compiler()
         or no_cc();
 }
 
 my %prereqs = (
-    'perl'          => '5.008',
-    'Scalar::Util'  => '1.18',
-    'Sub::Name'     => '0.04',
-    'Sub::Identify' => '0.03',
-    'MRO::Compat'   => '0.05',
-    'Carp'          => 0,
-    'Devel::GlobalDestruction' => 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{qw(Sub::Name Devel::GlobalDestruction)}
@@ -46,7 +52,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 <stevan@iinteractive.com>',
         LICENSE       => 'perl',
@@ -112,6 +118,21 @@ 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 get_pp_tests {
+    opendir my $dh, 't' or die "Cannot read t: $!";
+
+    return grep { $_ !~ /^99/ } grep {/^\d.+\.t$/} readdir $dh;
+}
+
 # This is EUMM voodoo
 sub init {
     my $hash = $_[1];
@@ -122,3 +143,27 @@ sub init {
 
     $hash;
 }
+
+package MY;
+
+sub postamble {
+    my @test_files = ::get_pp_tests();
+    my $pp_tests = join q{ }, map { File::Spec->catfile('t', "pp_${_}") } @test_files;
+    my @pp_test_targets = join qq{\n}, map {
+        my $source = File::Spec->catfile('t', ${_});
+        File::Spec->catfile('t', "pp_${_}") . q{: }
+        . qq{$source t/header_pp.inc\n\t}
+        . q{$(NOECHO) $(ABSPERLRUN) "-MExtUtils::Command" -e cat t/header_pp.inc }
+        . $source . q{ > $@} . qq{\n}
+    } @test_files;
+    my $test_dep = $::has_compiler && (::is_maintainer() || $ENV{AUTOMATED_TESTING})
+        ? qq{pure_all :: pp_tests\n} . join qq{\n}, @pp_test_targets
+        : '';
+
+    return <<"EOM"
+pp_tests: ${pp_tests}
+
+${test_dep}
+
+EOM
+}