Shuffle tests around (no changes)
[dbsrgits/DBIx-Class.git] / t / 53lean_startup.t
CommitLineData
3b80fa31 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
4
5my $test_hook;
6BEGIN {
7 $test_hook = sub {}; # noop at first
8 *CORE::GLOBAL::require = sub {
9 $test_hook->(@_);
10 CORE::require($_[0]);
11 };
12}
13
14use strict;
15use warnings;
16use Test::More;
17
18use Carp;
19
20BEGIN {
21 my $core_modules = { map { $_ => 1 } qw/
22 strict
23 warnings
24 vars
25
26 base
27 parent
28 mro
29 overload
30
31 B
32 locale
33
34 namespace::clean
35 Try::Tiny
36 Sub::Name
37
38 Scalar::Util
39 List::Util
40 Hash::Merge
41
42 DBI
70c28808 43 SQL::Abstract
3b80fa31 44
45 Carp
3b80fa31 46
47 Class::Accessor::Grouped
48 Class::C3::Componentised
3b80fa31 49 /, $] < 5.010 ? 'MRO::Compat' : () };
50
51 $test_hook = sub {
52
53 my $req = $_[0];
54 $req =~ s/\.pm$//;
55 $req =~ s/\//::/g;
56
57 return if $req =~ /^DBIx::Class|^DBICTest::Schema/;
58
59 my $up = 1;
60 my @caller;
61 do { @caller = caller($up++) } while (
62 @caller and (
63 $caller[0] =~ /^ (?: base | parent | Class::C3::Componentised | Module::Inspector) $/x
64 or
65 $caller[1] =~ / \( eval \s \d+ \) /x
66 )
67 );
68
69 if ( $caller[0] =~ /^DBIx::Class/) {
70 fail ("Unexpected require of '$req' by $caller[0] ($caller[1] line $caller[2])")
71 unless $core_modules->{$req};
72 }
73 };
74}
75
76use lib 't/lib';
77use DBICTest;
78
79# these envvars bring in more stuff
80delete $ENV{$_} for qw/
81 DBICTEST_SQLT_DEPLOY
82 DBIC_TRACE
83/;
84
85my $schema = DBICTest->init_schema;
86is ($schema->resultset('Artist')->next->name, 'Caterwauler McCrae');
87
88done_testing;