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 -It/lib -MANFANG -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 # in case we loaded warnings.pm / used -w
95 # ( do not do `no warnings ...` as it is also a load )
96 local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /redefined/ };
98 *UNIVERSAL::VERSION = sub {
99 Carp::carp( 'Argument "blah bleh bloh" isn\'t numeric in subroutine entry' );
106 $ENV{DBICTEST_ASSERT_NO_SPURIOUS_EXCEPTION_ACTION}
108 # keep it always on during CI
110 ($ENV{TRAVIS}||'') eq 'true'
112 ($ENV{TRAVIS_REPO_SLUG}||'') =~ m|\w+/dbix-class$|
115 # two levels of if() because of taint mode tangling the %ENV-checks
116 # with the require() call, sigh...
118 if ( eval { require Try::Tiny } ) {
119 my $orig = \&Try::Tiny::try;
121 # in case we loaded warnings.pm / used -w
122 # ( do not do `no warnings ...` as it is also a load )
123 local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /redefined/ };
125 *Try::Tiny::try = sub (&;@) {
126 my ($fr, $first_pkg) = 0;
127 while( $first_pkg = caller($fr++) ) {
128 last if $first_pkg !~ /^
135 if ($first_pkg =~ /DBIx::Class/) {
136 require Test::Builder;
137 Test::Builder->new->ok(0,
138 'Using try{} within DBIC internals is a mistake - use dbic_internal_try{} instead'
149 unshift @INC, 't/lib';
152 # everything expects this to be there
158 # creation is inherently racy
162 die "Unable to create 't/var': $err\n"
163 unless $err == Errno::EEXIST();
168 # Back in ab340f7f ribasushi stupidly introduced a "did you check your deps"
169 # verification tied very tightly to Module::Install. The check went away, and
170 # so eventually will M::I, but bisecting can bring all of this back from the
171 # dead. In order to reduce hair-pulling make sure that ./inc/ is always there
172 -f 'Makefile.PL' and mkdir 'inc' and mkdir 'inc/.author';
175 if( my @finalest_tasks = (
177 ( !$ENV{DBICTEST_DIRTY_EXIT} ? () : sub {
182 # Crucial flushes in case we are piping things out (e.g. prove)
183 # Otherwise the last lines will never arrive at the receiver
184 close($_) for \*STDOUT, \*STDERR;
191 # in the case of an early skip_all B may very well not have loaded
192 unless( $INC{"B.pm"} ) {
193 local ( $!, $^E, $?, $@ );
197 # Make sure we run after any cleanup in other END blocks
198 # ( push-to-end twice in a row )
199 push @{ B::end_av()->object_2svref }, sub {
200 push @{ B::end_av()->object_2svref }, @finalest_tasks;
205 # make absolutely sure this is last