[Moose-commits] r7241 - in Class-MOP/trunk: . t
rafl at code2.0beta.co.uk
rafl at code2.0beta.co.uk
Wed Jan 7 06:59:23 GMT 2009
Author: rafl
Date: 2009-01-06 22:59:23 -0800 (Tue, 06 Jan 2009)
New Revision: 7241
Added:
Class-MOP/trunk/t/header_pp.inc
Modified:
Class-MOP/trunk/Makefile.PL
Log:
Turn generation of pure perl tests into a makefile target.
Modified: Class-MOP/trunk/Makefile.PL
===================================================================
--- Class-MOP/trunk/Makefile.PL 2009-01-07 06:59:05 UTC (rev 7240)
+++ Class-MOP/trunk/Makefile.PL 2009-01-07 06:59:23 UTC (rev 7241)
@@ -18,7 +18,7 @@
/^--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();
@@ -41,10 +41,6 @@
delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)}
unless $has_compiler;
-if ($has_compiler && is_maintainer()) {
- create_pp_tests();
-}
-
write_makefile();
sub write_makefile {
@@ -131,32 +127,12 @@
return 1;
}
-sub create_pp_tests {
+sub get_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;
- }
+ return map {
+ File::Spec->catfile('t', "pp_${_}")
+ } grep { $_ !~ /^99/ } grep {/^\d.+\.t$/} readdir $dh;
}
# This is EUMM voodoo
@@ -169,3 +145,21 @@
$hash;
}
+
+package MY;
+
+sub postamble {
+ my $pp_tests = join q{ }, ::get_pp_tests();
+ my $test_dep = $::has_compiler && ::is_maintainer()
+ ? 'pure_all :: pp_tests'
+ : '';
+
+ return <<"EOM"
+pp_tests: ${pp_tests}
+
+${test_dep}
+
+t/pp_%: t/% t/header_pp.inc
+\t\$(NOECHO) \$(ABSPERLRUN) "-MExtUtils::Command" -e cat t/header_pp.inc \$< >> \$@
+EOM
+}
Added: Class-MOP/trunk/t/header_pp.inc
===================================================================
--- Class-MOP/trunk/t/header_pp.inc (rev 0)
+++ Class-MOP/trunk/t/header_pp.inc 2009-01-07 06:59:23 UTC (rev 7241)
@@ -0,0 +1,2 @@
+BEGIN { $ENV{CLASS_MOP_NO_XS} = 1 }
+
More information about the Moose-commits
mailing list