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 # a ghetto way of recognizing cperl without loading Config.pm
50 # the $] guard is there because touching $^V on pre-5.10 loads
51 # the entire utf8 stack (wtf!!!)
52 ( "$]" < 5.010 or $^V !~ /\d+c$/ )
56 # just don't check anything under RELEASE_TESTING
57 # a naive approach would be to simply whitelist both
58 # strict and warnings, but pre 5.10 there were even
59 # more modules loaded by these two:
61 # perlbrew exec perl -Mstrict -Mwarnings -e 'warn join "\n", sort keys %INC'
63 ! $ENV{RELEASE_TESTING}
67 my @undesirables = grep {
69 ($INC{$_}||'') ne __FILE__
73 # allow direct loads via -M
74 $_ !~ m{^ DBICTest (?: /Schema )? \.pm $}x
81 while (@frame = caller(++$fr)) {
82 last if $frame[1] !~ m{ (?: \A | [\/\\] ) t [\/\\] lib [\/\\] }x;
85 die __FILE__ . " must be loaded before any other module (i.e. @{[ join ', ', map { qq('$_') } sort @undesirables ]}) at $frame[1] line $frame[2]\n";
89 if ( $ENV{DBICTEST_VERSION_WARNS_INDISCRIMINATELY} ) {
90 my $ov = UNIVERSAL->can("VERSION");
94 # not loading warnings.pm
97 *UNIVERSAL::VERSION = sub {
98 Carp::carp( 'Argument "blah bleh bloh" isn\'t numeric in subroutine entry' );
105 $ENV{DBICTEST_ASSERT_NO_SPURIOUS_EXCEPTION_ACTION}
107 # keep it always on during CI
109 ($ENV{TRAVIS}||'') eq 'true'
111 ($ENV{TRAVIS_REPO_SLUG}||'') =~ m|\w+/dbix-class$|
115 my $orig = \&Try::Tiny::try;
117 # not loading warnings.pm
120 *Try::Tiny::try = sub (&;@) {
121 my ($fr, $first_pkg) = 0;
122 while( $first_pkg = caller($fr++) ) {
123 last if $first_pkg !~ /^
130 if ($first_pkg =~ /DBIx::Class/) {
131 require Test::Builder;
132 Test::Builder->new->ok(0,
133 'Using try{} within DBIC internals is a mistake - use dbic_internal_try{} instead'
144 lib->import('t/lib');
147 # everything expects this to be there
151 die "Unable to create 't/var': $!\n"
155 # Back in ab340f7f ribasushi stupidly introduced a "did you check your deps"
156 # verification tied very tightly to Module::Install. The check went away, and
157 # so eventually will M::I, but bisecting can bring all of this back from the
158 # dead. In order to reduce hair-pulling make sure that ./inc/ is always there
159 -f 'Makefile.PL' and mkdir 'inc' and mkdir 'inc/.author';
162 if( my @finalest_tasks = (
164 ( !$ENV{DBICTEST_DIRTY_EXIT} ? () : sub {
169 # Crucial flushes in case we are piping things out (e.g. prove)
170 # Otherwise the last lines will never arrive at the receiver
171 close($_) for \*STDOUT, \*STDERR;
178 # in the case of an early skip_all B may very well not have loaded
179 unless( $INC{"B.pm"} ) {
180 local ( $!, $^E, $?, $@ );
184 # Make sure we run after any cleanup in other END blocks
185 # ( push-to-end twice in a row )
186 push @{ B::end_av()->object_2svref }, sub {
187 push @{ B::end_av()->object_2svref }, @finalest_tasks;
192 # make absolutely sure this is last