1 # Use a require override instead of @INC munging (less common)
2 # Do the override as early as possible so that CORE::require doesn't get compiled away
3 # We will replace $req_override in a bit
7 $test_hook = sub {}; # noop at first
8 *CORE::GLOBAL::require = sub {
17 # this is only being used because Data::Compare is dumb and has a weird
18 # plugin infrastructure and ends up loading a bunch of random stuff for
23 my $core_modules = { map { $_ => 1 } qw/
49 Class::Accessor::Grouped
50 Class::C3::Componentised
53 /, $] < 5.010 ? 'MRO::Compat' : () };
61 return if $req =~ /^DBIx::Class|^DBICTest::Schema/;
65 do { @caller = caller($up++) } while (
67 $caller[0] =~ /^ (?: base | parent | Class::C3::Componentised | Module::Inspector) $/x
69 $caller[1] =~ / \( eval \s \d+ \) /x
73 if ( $caller[0] =~ /^DBIx::Class/) {
74 fail ("Unexpected require of '$req' by $caller[0] ($caller[1] line $caller[2])")
75 unless $core_modules->{$req};
83 # these envvars bring in more stuff
84 delete $ENV{$_} for qw/
89 my $schema = DBICTest->init_schema;
90 is ($schema->resultset('Artist')->next->name, 'Caterwauler McCrae');