From: Peter Rabbitson Date: Fri, 23 Nov 2012 15:44:43 +0000 (+0100) Subject: B::H::EOS is now PP-capable on its own X-Git-Tag: 0.24~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=727a1a2fe2c69811af11fc9bb0035e5982322c36;p=p5sagit%2Fnamespace-clean.git B::H::EOS is now PP-capable on its own --- diff --git a/Changes b/Changes index 27ff8ee..c28a244 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ - Properly skip debugger test when optional deps not available - Make sure pure-perl tests pass correctly on space-containing paths (RT#77528) + - Remove all the pure-perl fallback code and depend on PP-capable + B::H::EOS 0.12 [0.23] - Rely on B::Hooks::EndOfScope version 0.10 to fix issues with diff --git a/Makefile.PL b/Makefile.PL index 7eb5297..a8d2d1f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,20 +13,14 @@ my %BUILD_DEPS = ( my %RUN_DEPS = ( 'Package::Stash' => '0.23', + 'B::Hooks::EndOfScope' => '0.12', ); -my %OPT_RUN_DEPS = (can_cc() ? ( - 'B::Hooks::EndOfScope' => '0.10', # when changing, also change $b_h_eos_req in namespace/clean.pm - - # these pieces are needed if using the debugger on the perl range - ($] > 5.008_008_9 && $] < 5.013_005_1) - ? ( 'Sub::Name' => '0.04', 'Sub::Identify' => '0.04' ) # when changing, also change $sn_ver and $si_ver in namespace/clean.pm - : () - , - - # make sure we smoke the pure-perl version - is_smoker() ? ( 'Devel::Hide' => 0 ) : (), -) : () ); +# these pieces are needed if using the debugger on the perl range +my %OPT_RUN_DEPS = ( $] > 5.008_008_9 and $] < 5.013_005_1 and can_xs() ) + # when changing versions, also change $sn_ver and $si_ver in namespace/clean.pm + ? ( 'Sub::Name' => '0.04', 'Sub::Identify' => '0.04' ) : () +; my %META_BITS = ( resources => { @@ -53,8 +47,8 @@ my %WriteMakefileArgs = ( 'VERSION_FROM' => 'lib/namespace/clean.pm', 'ABSTRACT' => 'Keep imports and functions out of your namespace', 'AUTHOR' => 'Robert \'phaylon\' Sedlacek , Florian Ragwitz , Jesse Luehrs ', - - 'PREREQ_PM' => { + 'CONFIGURE_REQUIRES' => { 'ExtUtils::CBuilder' => 0.27 }, + 'PREREQ_PM' => { %RUN_DEPS, %OPT_RUN_DEPS, $mymeta_works ? () : (%BUILD_DEPS), }, @@ -100,6 +94,20 @@ delete $WriteMakefileArgs{CONFIGURE_REQUIRES} WriteMakefile(%WriteMakefileArgs); +# Secondary compile testing via ExtUtils::CBuilder +sub can_xs { + # Do we have the configure_requires checker? + local $@; + eval "require ExtUtils::CBuilder;"; + if (! $@ ) { + # They don't obey configure_requires, so it is + # someone old and delicate. Try to avoid hurting + # them by falling back to an older simpler test. + return can_cc(); + } + + return ExtUtils::CBuilder->new( quiet => 1 )->have_compiler; +} # can we locate a (the) C compiler sub can_cc { @@ -130,7 +138,3 @@ sub can_run { return; } - -sub is_smoker { - return ( $ENV{AUTOMATED_TESTING} && ! $ENV{PERL5_CPANM_IS_RUNNING} && ! $ENV{RELEASE_TESTING} ) -} diff --git a/lib/namespace/clean.pm b/lib/namespace/clean.pm index c030700..6d479d9 100644 --- a/lib/namespace/clean.pm +++ b/lib/namespace/clean.pm @@ -3,34 +3,12 @@ package namespace::clean; use warnings; use strict; -use vars qw( $STORAGE_VAR ); use Package::Stash; our $VERSION = '0.23'; +our $STORAGE_VAR = '__NAMESPACE_CLEAN_STORAGE'; -$STORAGE_VAR = '__NAMESPACE_CLEAN_STORAGE'; - -# FIXME - all of this buggery will migrate to B::H::EOS soon -BEGIN { - # when changing also change in Makefile.PL - my $b_h_eos_req = '0.10'; - - if (! $ENV{NAMESPACE_CLEAN_USE_PP} and eval { - require B::Hooks::EndOfScope; - B::Hooks::EndOfScope->VERSION($b_h_eos_req); - 1 - } ) { - B::Hooks::EndOfScope->import('on_scope_end'); - } - elsif ($] < 5.009_003_1) { - require namespace::clean::_PP_OSE_5_8; - *on_scope_end = \&namespace::clean::_PP_OSE_5_8::on_scope_end; - } - else { - require namespace::clean::_PP_OSE; - *on_scope_end = \&namespace::clean::_PP_OSE::on_scope_end; - } -} +use B::Hooks::EndOfScope 'on_scope_end'; =head1 NAME diff --git a/lib/namespace/clean/_PP_OSE.pm b/lib/namespace/clean/_PP_OSE.pm deleted file mode 100644 index 2a897a0..0000000 --- a/lib/namespace/clean/_PP_OSE.pm +++ /dev/null @@ -1,40 +0,0 @@ -package # hide from the pauses - namespace::clean::_PP_OSE; - -use warnings; -use strict; - -use Tie::Hash; -use Hash::Util::FieldHash 'fieldhash'; - -# Here we rely on a combination of several behaviors: -# -# * %^H is deallocated on scope exit, so any references to it disappear -# * A lost weakref in a fieldhash causes the corresponding key to be deleted -# * Deletion of a key on a tied hash triggers DELETE -# -# Therefore the DELETE of a tied fieldhash containing a %^H reference will -# be the hook to fire all our callbacks. - -fieldhash my %hh; -{ - package # hide from pause too - namespace::clean::_TieHintHashFieldHash; - use base 'Tie::StdHash'; - sub DELETE { - my $ret = shift->SUPER::DELETE(@_); - $_->() for @$ret; - $ret; - } -} - -sub on_scope_end (&) { - $^H |= 0x020000; - - tie(%hh, 'namespace::clean::_TieHintHashFieldHash') - unless tied %hh; - - push @{ $hh{\%^H} ||= [] }, shift; -} - -1; diff --git a/lib/namespace/clean/_PP_OSE_5_8.pm b/lib/namespace/clean/_PP_OSE_5_8.pm deleted file mode 100644 index 302463c..0000000 --- a/lib/namespace/clean/_PP_OSE_5_8.pm +++ /dev/null @@ -1,26 +0,0 @@ -package # hide from the pauses - namespace::clean::_PP_OSE_5_8; - -use warnings; -use strict; - -# This is the original implementation, which sadly is broken -# on perl 5.10+ withing string evals -sub on_scope_end (&) { - $^H |= 0x020000; - - push @{ - $^H{'__namespace::clean__guardstack__'} - ||= bless ([], 'namespace::clean::_PP_SG_STACK') - }, shift; -} - -package # hide from the pauses - namespace::clean::_PP_SG_STACK; - -use warnings; -use strict; - -sub DESTROY { $_->() for @{$_[0]} } - -1; diff --git a/t/10-pure-perl.t b/t/10-pure-perl.t index edf3f05..704ed30 100644 --- a/t/10-pure-perl.t +++ b/t/10-pure-perl.t @@ -5,12 +5,13 @@ use Test::More; plan skip_all => "PP tests already executed" if $ENV{NAMESPACE_CLEAN_USE_PP}; -eval { require B::Hooks::EndOfScope } +eval { require Variable::Magic } or plan skip_all => "PP tests already executed"; -# the PP tests will run either wih D::H (mainly on smokers) -# or by setting the envvar (for users) -my $has_d_h = eval { require Devel::Hide }; +$ENV{B_HOOKS_ENDOFSCOPE_IMPLEMENTATION} = 'PP'; +require B::Hooks::EndOfScope; +ok( ($INC{'B/Hooks/EndOfScope/PP.pm'} && ! $INC{'B/Hooks/EndOfScope/XS.pm'}), + 'PP BHEOS loaded properly'); use Config; use FindBin qw($Bin); @@ -20,19 +21,14 @@ use File::Glob 'bsd_glob'; # for the $^X-es $ENV{PERL5LIB} = join ($Config{path_sep}, @INC); + # rerun the tests under the assumption of pure-perl my $this_file = quotemeta(__FILE__); for my $fn (bsd_glob("$Bin/*.t")) { next if $fn =~ /${this_file}$/; - local $ENV{DEVEL_HIDE_VERBOSE} = 0; - local $ENV{NAMESPACE_CLEAN_USE_PP} = 1 unless $has_d_h; - my @cmd = ( - $^X, - $has_d_h ? '-MDevel::Hide=B::Hooks::EndOfScope' : (), - $fn - ); + my @cmd = ($^X, $fn); # this is cheating, and may even hang here and there (testing on windows passed fine) # if it does - will have to fix it somehow (really *REALLY* don't want to pull