From: Graham Knop Date: Sat, 9 Mar 2013 19:47:57 +0000 (-0500) Subject: 5.6 compat X-Git-Tag: Devel-GlobalDestruction-0.10~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4be4bd8bf54216cf2a58041f82f5fdaead5850a;hp=b1bee216b13ba067c620587ce49899927e103970;p=p5sagit%2FDevel-GlobalDestruction.git 5.6 compat --- diff --git a/Makefile.PL b/Makefile.PL index ae92f14..b251d5a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,7 +1,7 @@ use strict; use warnings; -require 5.008001; +require 5.006; use ExtUtils::MakeMaker; BEGIN { if ( $^O eq 'cygwin' ) { @@ -25,7 +25,7 @@ my $mymeta = $mymeta_works || eval { ExtUtils::MakeMaker->VERSION('6.5702'); 1 } my %META_BITS = ( ); my %RUN_DEPS = ( - 'Sub::Exporter::Progressive' => 0.001002, + 'Sub::Exporter::Progressive' => '0.001002', ( (defined ${^GLOBAL_PHASE} or !can_xs() ) ? () : ('Devel::GlobalDestruction::XS' => 0) @@ -38,7 +38,7 @@ my %WriteMakefileArgs = ( LICENSE => 'perl', INSTALLDIRS => 'site', PL_FILES => { }, - MIN_PERL_VERSION => '5.008001', + MIN_PERL_VERSION => '5.006', PREREQ_PM => \%RUN_DEPS, CONFIGURE_REQUIRES => { 'ExtUtils::CBuilder' => 0.27 }, META_ADD => { diff --git a/lib/Devel/GlobalDestruction.pm b/lib/Devel/GlobalDestruction.pm index 36a1feb..c4d72a2 100644 --- a/lib/Devel/GlobalDestruction.pm +++ b/lib/Devel/GlobalDestruction.pm @@ -20,6 +20,7 @@ if (defined ${^GLOBAL_PHASE}) { # elsif (eval { require Devel::GlobalDestruction::XS; + no warnings 'once'; *in_global_destruction = \&Devel::GlobalDestruction::XS::in_global_destruction; 1; }) { @@ -32,10 +33,11 @@ else { require B; my $started = !B::main_start()->isa(q[B::NULL]); unless ($started) { - eval 'CHECK { $started = 1 }; 1' + # work around 5.6 eval bug + eval '0 && $started; CHECK { $started = 1 }; 1' or die $@; } - eval 'sub in_global_destruction () { $started && B::main_start()->isa(q[B::NULL]) }; 1' + eval '0 && $started; sub in_global_destruction () { $started && B::main_start()->isa(q[B::NULL]) }; 1' or die $@; } diff --git a/t/01_basic.t b/t/01_basic.t index 85d5624..95e61b3 100644 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -21,25 +21,31 @@ our $had_error; # try to ensure this is the last-most END so we capture future tests # running in other ENDs -require B; -my $reinject_retries = my $max_retry = 5; -my $end_worker; -$end_worker = sub { - my $tail = (B::end_av()->ARRAY)[-1]; - if (!defined $tail or $tail == $end_worker) { - $? = $had_error || 0; - $reinject_retries = 0; - } - elsif ($reinject_retries--) { - push @{B::end_av()->object_2svref}, $end_worker; - } - else { - print STDERR "\n\nSomething is racing with @{[__FILE__]} for final END block definition - can't win after $max_retry iterations :(\n\n"; - require POSIX; - POSIX::_exit( 255 ); - } -}; -END { push @{B::end_av()->object_2svref}, $end_worker } +if ($[ >= 5.008) { + require B; + my $reinject_retries = my $max_retry = 5; + my $end_worker; + $end_worker = sub { + my $tail = (B::end_av()->ARRAY)[-1]; + if (!defined $tail or $tail == $end_worker) { + $? = $had_error || 0; + $reinject_retries = 0; + } + elsif ($reinject_retries--) { + push @{B::end_av()->object_2svref}, $end_worker; + } + else { + print STDERR "\n\nSomething is racing with @{[__FILE__]} for final END block definition - can't win after $max_retry iterations :(\n\n"; + require POSIX; + POSIX::_exit( 255 ); + } + }; + eval 'END { push @{B::end_av()->object_2svref}, $end_worker }'; +} +# B::end_av isn't available on 5.6, so just use a basic end block +else { + eval 'END { $? = $had_error || 0 }'; +} sub ok ($$) { $had_error++, print "not " if !$_[0]; @@ -62,7 +68,8 @@ ok( prototype \&in_global_destruction eq "", "empty prototype" ); ok( ! in_global_destruction(), "Runtime is not GD" ); -our $sg1 = Test::Scope::Guard->new(sub { ok( in_global_destruction(), "Final cleanup object destruction properly in GD" ) }); +our $sg1; +$sg1 = Test::Scope::Guard->new(sub { ok( in_global_destruction(), "Final cleanup object destruction properly in GD" ) }); END { ok( ! in_global_destruction(), 'Not yet in GD while in END block 1' ) diff --git a/t/10_pure-perl.t b/t/10_pure-perl.t index 47bfbc2..3246c03 100644 --- a/t/10_pure-perl.t +++ b/t/10_pure-perl.t @@ -3,7 +3,6 @@ use warnings; use FindBin qw($Bin); use Config; use IPC::Open2; -use File::Glob 'bsd_glob'; # support spaces in names unlike glob() # rerun the tests under the assumption of pure-perl @@ -13,7 +12,8 @@ $ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST} = 1; my $this_file = quotemeta(__FILE__); -my @tests = grep { $_ !~ /${this_file}$/ } bsd_glob("$Bin/*.t"); +opendir(my $dh, $Bin); +my @tests = grep { $_ !~ /${this_file}$/ } map { "$Bin/$_" } grep { /\.t$/ } readdir $dh; print "1..@{[ scalar @tests ]}\n"; my $had_error = 0;