# this allows the obscure but possible call case to behave correctly:
#
-# perl -Mt::lib::ANFANG -e 'do "./t/lib/ANFANG.pm" or die ( $@ || $! )'
+# perl -It/lib -MANFANG -e 'do "./t/lib/ANFANG.pm" or die ( $@ || $! )'
#
return 1 if $anfang_loaded;
and
+ # a ghetto way of recognizing cperl without loading Config.pm
+ # the $] guard is there because touching $^V on pre-5.10 loads
+ # the entire utf8 stack (wtf!!!)
+ ( "$]" < 5.010 or $^V !~ /\d+c$/ )
+
+ and
+
# just don't check anything under RELEASE_TESTING
# a naive approach would be to simply whitelist both
# strict and warnings, but pre 5.10 there were even
require Carp;
- # not loading warnings.pm
- local $^W = 0;
+ # in case we loaded warnings.pm / used -w
+ # ( do not do `no warnings ...` as it is also a load )
+ local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /redefined/ };
*UNIVERSAL::VERSION = sub {
Carp::carp( 'Argument "blah bleh bloh" isn\'t numeric in subroutine entry' );
($ENV{TRAVIS_REPO_SLUG}||'') =~ m|\w+/dbix-class$|
)
) {
- require Try::Tiny;
- my $orig = \&Try::Tiny::try;
-
- # not loading warnings.pm
- local $^W = 0;
-
- *Try::Tiny::try = sub (&;@) {
- my ($fr, $first_pkg) = 0;
- while( $first_pkg = caller($fr++) ) {
- last if $first_pkg !~ /^
- __ANON__
- |
- \Q(eval)\E
- $/x;
- }
-
- if ($first_pkg =~ /DBIx::Class/) {
- require Test::Builder;
- Test::Builder->new->ok(0,
- 'Using try{} within DBIC internals is a mistake - use dbic_internal_try{} instead'
- );
- }
-
- goto $orig;
- };
+ # two levels of if() because of taint mode tangling the %ENV-checks
+ # with the require() call, sigh...
+
+ if ( eval { require Try::Tiny } ) {
+ my $orig = \&Try::Tiny::try;
+
+ # in case we loaded warnings.pm / used -w
+ # ( do not do `no warnings ...` as it is also a load )
+ local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /redefined/ };
+
+ *Try::Tiny::try = sub (&;@) {
+ my ($fr, $first_pkg) = 0;
+ while( $first_pkg = caller($fr++) ) {
+ last if $first_pkg !~ /^
+ __ANON__
+ |
+ \Q(eval)\E
+ $/x;
+ }
+
+ if ($first_pkg =~ /DBIx::Class/) {
+ require Test::Builder;
+ Test::Builder->new->ok(0,
+ 'Using try{} within DBIC internals is a mistake - use dbic_internal_try{} instead'
+ );
+ }
+
+ goto $orig;
+ };
+ }
}
}
-require lib;
-lib->import('t/lib');
+unshift @INC, 't/lib';
# everything expects this to be there
-! -d 't/var' and (
+! -d 't/var'
+ and
+(
mkdir 't/var'
or
- die "Unable to create 't/var': $!\n"
+ # creation is inherently racy
+ do {
+ my $err = $!;
+ require Errno;
+ die "Unable to create 't/var': $err\n"
+ unless $err == Errno::EEXIST();
+ }
);
# Crucial flushes in case we are piping things out (e.g. prove)
# Otherwise the last lines will never arrive at the receiver
- select($_), $| = 1 for \*STDOUT, \*STDERR;
+ close($_) for \*STDOUT, \*STDERR;
POSIX::_exit($exit);
} ),