X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FANFANG.pm;h=bdae98362627d9f64aa2f5295f33bd22c7315357;hb=10dd5c05fee5be6ff4d72e41ab0d7b51809fdb5a;hp=354bc013806bda8a7cfe3d8042bc9c70aa06c46f;hpb=bd52af73fba43175e16439d2a241dbf9d468cd5f;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/ANFANG.pm b/t/lib/ANFANG.pm index 354bc01..bdae983 100644 --- a/t/lib/ANFANG.pm +++ b/t/lib/ANFANG.pm @@ -151,6 +151,36 @@ lib->import('t/lib'); # dead. In order to reduce hair-pulling make sure that ./inc/ is always there -f 'Makefile.PL' and mkdir 'inc' and mkdir 'inc/.author'; +END { + if( my @finalest_tasks = ( + + ( !$ENV{DBICTEST_DIRTY_EXIT} ? () : sub { + + my $exit = $?; + require POSIX; + + # 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; + + POSIX::_exit($exit); + } ), + + )) { + + # in the case of an early skip_all B may very well not have loaded + unless( $INC{"B.pm"} ) { + local ( $!, $^E, $?, $@ ); + require B; + } + + # Make sure we run after any cleanup in other END blocks + # ( push-to-end twice in a row ) + push @{ B::end_av()->object_2svref }, sub { + push @{ B::end_av()->object_2svref }, @finalest_tasks; + } + } +} # make absolutely sure this is last $anfang_loaded = 1;