From: Peter Rabbitson Date: Tue, 9 Aug 2016 08:53:30 +0000 (+0200) Subject: Some cosmetic fixes in ANFANG X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=50841788d03e2342a00470eb2f458e717922615b;p=dbsrgits%2FDBIx-Class.git Some cosmetic fixes in ANFANG --- diff --git a/t/lib/ANFANG.pm b/t/lib/ANFANG.pm index 4e49fe0..c60ba9e 100644 --- a/t/lib/ANFANG.pm +++ b/t/lib/ANFANG.pm @@ -91,8 +91,9 @@ $INC{$_} ||= __FILE__ for (qw( ANFANG.pm t/lib/ANFANG.pm ./t/lib/ANFANG.pm )); 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' ); @@ -114,8 +115,9 @@ $INC{$_} ||= __FILE__ for (qw( ANFANG.pm t/lib/ANFANG.pm ./t/lib/ANFANG.pm )); require Try::Tiny; my $orig = \&Try::Tiny::try; - # 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/ }; *Try::Tiny::try = sub (&;@) { my ($fr, $first_pkg) = 0; @@ -140,15 +142,22 @@ $INC{$_} ||= __FILE__ for (qw( ANFANG.pm t/lib/ANFANG.pm ./t/lib/ANFANG.pm )); } -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(); + } );