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