X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Fextra%2Finternals%2Fnamespaces_cleaned.t;h=e5d74acbded774f7978100b5b0f35ca735fb7a40;hb=e85eb407cd475abef6c489dfd36b4866785e00be;hp=00236021e78a8f03f0a5fbb1ee8d445c1e462c36;hpb=c26b30dee587fa008f7d956b61ae27c36ac7ec82;p=dbsrgits%2FDBIx-Class.git diff --git a/xt/extra/internals/namespaces_cleaned.t b/xt/extra/internals/namespaces_cleaned.t index 0023602..e5d74ac 100644 --- a/xt/extra/internals/namespaces_cleaned.t +++ b/xt/extra/internals/namespaces_cleaned.t @@ -1,5 +1,7 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + BEGIN { - if ($] < 5.010) { + if ( "$]" < 5.010) { # Pre-5.10 perls pollute %INC on unsuccesfull module # require, making it appear as if the module is already @@ -16,7 +18,7 @@ BEGIN { # we want to do this here, in the very beginning, before even # warnings/strict are loaded - unshift @INC, 't/lib'; + require DBICTest::Util::OverrideRequire; DBICTest::Util::OverrideRequire::override_global_require( sub { @@ -33,15 +35,35 @@ BEGIN { use strict; use warnings; -use Test::More; +# FIXME This is a crock of shit, needs to go away +# currently here to work around https://rt.cpan.org/Ticket/Display.html?id=74151 +# kill with fire when PS::XS / RT#74151 is *finally* fixed +BEGIN { + my $PS_provider; -use lib 't/lib'; + if ( "$]" < 5.010 ) { + require Package::Stash::PP; + $PS_provider = 'Package::Stash::PP'; + } + else { + require Package::Stash; + $PS_provider = 'Package::Stash'; + } + eval <<"EOS" or die $@; + +sub stash_for (\$) { + $PS_provider->new(\$_[0]); +} +1; +EOS +} + +use Test::More; use DBICTest; use File::Find; use File::Spec; use B qw/svref_2object/; -use Package::Stash; # makes sure we can load at least something use DBIx::Class; @@ -65,8 +87,7 @@ my @modules = grep { # have an exception table for old and/or weird code we are not sure # we *want* to clean in the first place my $skip_idx = { map { $_ => 1 } ( - (grep { /^DBIx::Class::CDBICompat/ } @modules), # too crufty to touch - 'SQL::Translator::Producer::DBIx::Class::File', # ditto + 'SQL::Translator::Producer::DBIx::Class::File', # too crufty to touch # not sure how to handle type libraries 'DBIx::Class::Storage::DBI::Replicated::Types', @@ -88,12 +109,6 @@ my $skip_idx = { map { $_ => 1 } ( my $has_moose = eval { require Moose::Util }; -Sub::Defer::undefer_all(); - -# can't use Class::Inspector for the mundane parts as it does not -# distinguish imports from anything else, what a crock of... -# Moose is not always available either - hence just do it ourselves - my $seen; #inheritance means we will see the same method multiple times for my $mod (@modules) { @@ -101,7 +116,7 @@ for my $mod (@modules) { skip "$mod exempt from namespace checks",1 if $skip_idx->{$mod}; my %all_method_like = (map - { %{Package::Stash->new($_)->get_all_symbols('CODE')} } + { %{stash_for($_)->get_all_symbols('CODE')} } (reverse @{mro::get_linear_isa($mod)}) ); @@ -150,6 +165,9 @@ for my $mod (@modules) { # exception time if ( ( $name eq 'import' and $via = 'Exporter' ) + or + # jesus christ nobody had any idea how to design an interface back then + ( $name =~ /_trigger/ and $via = 'Class::Trigger' ) ) { pass("${mod}::${name} is a valid uncleaned import from ${name}"); } @@ -185,15 +203,21 @@ for my $mod (@modules) { sub find_modules { my @modules; - find({ + find( { wanted => sub { -f $_ or return; + $_ =~ m|lib/DBIx/Class/_TempExtlib| and return; s/\.pm$// or return; s/^ (?: lib | blib . (?:lib|arch) ) . //x; push @modules, join ('::', File::Spec->splitdir($_)); }, no_chdir => 1, - }, (-e 'blib' ? 'blib' : 'lib') ); + }, ( + # find them in both lib and blib, duplicates are fine, since + # @INC is preadjusted for us by the harness + 'lib', + ( -e 'blib' ? 'blib' : () ), + )); return sort @modules; }