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