From: Dave Rolsky Date: Wed, 3 Sep 2008 17:09:56 +0000 (+0000) Subject: Run all the tests twice if we have XS, once with XS & once without. X-Git-Tag: 0.66~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c5aa6e2c97bf159941256635217c605ce50fac9;p=gitmo%2FClass-MOP.git Run all the tests twice if we have XS, once with XS & once without. This should help us maintainers make less buggy releases, I hope. --- diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index a356757..59b30ef 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -22,3 +22,4 @@ bench \.shipit t/pod\.t$ t/pod_coverage\.t$ +t/pp_.+\.t$ diff --git a/Makefile.PL b/Makefile.PL index 715ca88..4dbda50 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -39,6 +39,10 @@ my %prereqs = ( delete @prereqs{qw(Sub::Name Devel::GlobalDestruction)} unless $has_compiler; +if ($has_compiler && is_maintainer()) { + create_pp_tests(); +} + write_makefile(); sub write_makefile { @@ -50,7 +54,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', @@ -116,6 +120,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];