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 {
20 my $core_modules = { map { $_ => 1 } qw/
45 Class::Accessor::Grouped
46 Class::C3::Componentised
47 /, $] < 5.010 ? ( 'Class::C3', 'MRO::Compat' ) : () }; # this is special-cased in DBIx/Class.pm
55 return if $req =~ /^DBIx::Class|^DBICTest::/;
59 do { @caller = caller($up++) } while (
61 # exclude our test suite, known "module require-rs" and eval frames
62 $caller[1] =~ /^ t [\/\\] /x
64 $caller[0] =~ /^ (?: base | parent | Class::C3::Componentised | Module::Inspector) $/x
66 $caller[3] eq '(eval)',
70 # exclude everything where the current namespace does not match the called function
71 # (this works around very weird XS-induced require callstack corruption)
73 !$core_modules->{$req}
77 $caller[0] =~ /^DBIx::Class/
79 (caller($up))[3] =~ /\Q$caller[0]/
81 fail ("Unexpected require of '$req' by $caller[0] ($caller[1] line $caller[2])");
83 if ($ENV{TEST_VERBOSE}) {
85 while (my @f = caller($i++) ) {
97 # these envvars bring in more stuff
98 delete $ENV{$_} for qw/
103 my $schema = DBICTest->init_schema;
104 is ($schema->resultset('Artist')->next->name, 'Caterwauler McCrae');