X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F53lean_startup.t;h=248925ad9e11c3ed9099177b8ffe9776e76e1be0;hb=1b5ddf236a7911b6686be06602ffd657372523c2;hp=81f9bca05d4c1a7bc2dcacaadaa57e5f8b938905;hpb=f873b733054ccaac282fa056adfe41d5fd987840;p=dbsrgits%2FDBIx-Class.git diff --git a/t/53lean_startup.t b/t/53lean_startup.t index 81f9bca..248925a 100644 --- a/t/53lean_startup.t +++ b/t/53lean_startup.t @@ -1,20 +1,29 @@ # Use a require override instead of @INC munging (less common) # Do the override as early as possible so that CORE::require doesn't get compiled away -# We will replace $req_override in a bit +# We will add the hook in a bit, got to load some regular stuff my $test_hook; BEGIN { - $test_hook = sub {}; # noop at first - *CORE::GLOBAL::require = sub { - $test_hook->(@_); - CORE::require($_[0]); - }; + unshift @INC, 't/lib'; + require DBICTest::Util::OverrideRequire; + + DBICTest::Util::OverrideRequire::override_global_require( sub { + my $res = $_[0]->(); + $test_hook->($_[1]) if $test_hook; + return $res; + }); } use strict; use warnings; use Test::More; -use Data::Dumper; +use DBICTest::Util 'stacktrace'; + +# Package::Stash::XS is silly and fails if a require hook contains regular +# expressions on perl < 5.8.7. Load the damned thing if the case +BEGIN { + require Package::Stash if $] < 5.008007; +} my $expected_core_modules; @@ -23,15 +32,19 @@ BEGIN { strict warnings + constant + Config + base mro overload + Exporter B - locale - + Devel::GlobalDestruction namespace::clean Try::Tiny + Context::Preserve Sub::Name Scalar::Util @@ -40,12 +53,15 @@ BEGIN { Data::Compare DBI + DBI::Const::GetInfoType SQL::Abstract Carp Class::Accessor::Grouped Class::C3::Componentised + Moo + Sub::Quote /, $] < 5.010 ? ( 'Class::C3', 'MRO::Compat' ) : () }; # this is special-cased in DBIx/Class.pm $test_hook = sub { @@ -82,13 +98,7 @@ BEGIN { ) { fail ("Unexpected require of '$req' by $caller[0] ($caller[1] line $caller[2])"); - if ($ENV{TEST_VERBOSE}) { - my ($i, @stack) = 1; - while (my @f = caller($i++) ) { - push @stack, \@f; - } - diag Dumper(\@stack); - } + diag( 'Require invoked' . stacktrace() ) if $ENV{TEST_VERBOSE}; } }; } @@ -112,7 +122,7 @@ for (keys %$expected_core_modules) { $mod =~ s/::/\//g; unless ($INC{$mod}) { my $err = sprintf "Expected DBIC core module %s never loaded - %s needs adjustment", $_, __FILE__; - if (DBICTest::RunMode->is_smoker) { + if (DBICTest::RunMode->is_smoker or DBICTest::RunMode->is_author) { fail ($err) } else {