1 package # hide from pauses
6 if ( $ENV{RELEASE_TESTING} ) {
7 require warnings and warnings->import;
8 require strict and strict->import;
13 # FROM THIS POINT ONWARD EVERYTHING HAPPENS LINEARLY AT RUNTIME
17 # this allows the obscure but possible call case to behave correctly:
19 # perl -Mt::lib::ANFANG -e 'do "./t/lib/ANFANG.pm" or die ( $@ || $! )'
21 return 1 if $anfang_loaded;
23 # cover even more bases
24 $INC{$_} ||= __FILE__ for (qw( ANFANG.pm t/lib/ANFANG.pm ./t/lib/ANFANG.pm ));
27 # load-me-first sanity check
31 ! $ENV{DBICTEST_ANFANG_DEFANG}
35 # if these are set - all bets are off
39 scalar grep { $_ =~ m| \/ sitecustomize\.pl $ |x } keys %INC
44 # -d:Confess / -d:TraceUse and the like
49 # just don't check anything under RELEASE_TESTING
50 # a naive approach would be to simply whitelist both
51 # strict and warnings, but pre 5.10 there were even
52 # more modules loaded by these two:
54 # perlbrew exec perl -Mstrict -Mwarnings -e 'warn join "\n", sort keys %INC'
56 ! $ENV{RELEASE_TESTING}
60 my @undesirables = grep {
62 ($INC{$_}||'') ne __FILE__
66 # allow direct loads via -M
67 $_ !~ m{^ DBICTest (?: /Schema )? \.pm $}x
74 while (@frame = caller(++$fr)) {
75 last if $frame[1] !~ m{ (?: \A | [\/\\] ) t [\/\\] lib [\/\\] }x;
78 die __FILE__ . " must be loaded before any other module (i.e. @{[ join ', ', map { qq('$_') } sort @undesirables ]}) at $frame[1] line $frame[2]\n";
82 if ( $ENV{DBICTEST_VERSION_WARNS_INDISCRIMINATELY} ) {
83 my $ov = UNIVERSAL->can("VERSION");
87 # not loading warnings.pm
90 *UNIVERSAL::VERSION = sub {
91 Carp::carp( 'Argument "blah bleh bloh" isn\'t numeric in subroutine entry' );
98 $ENV{DBICTEST_ASSERT_NO_SPURIOUS_EXCEPTION_ACTION}
100 # keep it always on during CI
102 ($ENV{TRAVIS}||'') eq 'true'
104 ($ENV{TRAVIS_REPO_SLUG}||'') =~ m|\w+/dbix-class$|
108 my $orig = \&Try::Tiny::try;
110 # not loading warnings.pm
113 *Try::Tiny::try = sub (&;@) {
114 my ($fr, $first_pkg) = 0;
115 while( $first_pkg = caller($fr++) ) {
116 last if $first_pkg !~ /^
123 if ($first_pkg =~ /DBIx::Class/) {
124 require Test::Builder;
125 Test::Builder->new->ok(0,
126 'Using try{} within DBIC internals is a mistake - use dbic_internal_try{} instead'
137 lib->import('t/lib');
140 # everything expects this to be there
144 die "Unable to create 't/var': $!\n"
148 # Back in ab340f7f ribasushi stupidly introduced a "did you check your deps"
149 # verification tied very tightly to Module::Install. The check went away, and
150 # so eventually will M::I, but bisecting can bring all of this back from the
151 # dead. In order to reduce hair-pulling make sure that ./inc/ is always there
152 -f 'Makefile.PL' and mkdir 'inc' and mkdir 'inc/.author';
155 if( my @finalest_tasks = (
157 ( !$ENV{DBICTEST_DIRTY_EXIT} ? () : sub {
162 # Crucial flushes in case we are piping things out (e.g. prove)
163 # Otherwise the last lines will never arrive at the receiver
164 close($_) for \*STDOUT, \*STDERR;
171 # in the case of an early skip_all B may very well not have loaded
172 unless( $INC{"B.pm"} ) {
173 local ( $!, $^E, $?, $@ );
177 # Make sure we run after any cleanup in other END blocks
178 # ( push-to-end twice in a row )
179 push @{ B::end_av()->object_2svref }, sub {
180 push @{ B::end_av()->object_2svref }, @finalest_tasks;
185 # make absolutely sure this is last