From: Peter Rabbitson Date: Thu, 22 Jan 2015 15:19:57 +0000 (+0100) Subject: Keep T::B IO open in t/52leaks.t END - other ENDs pending (esp. since 961d79db) X-Git-Tag: v0.082820~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=6006b4a9445c72860c29de2549c244b01bb1b4c8 Keep T::B IO open in t/52leaks.t END - other ENDs pending (esp. since 961d79db) Read under -w (cherry pick of 7617dcc4) --- diff --git a/t/52leaks.t b/t/52leaks.t index 0a907ef..b186480 100644 --- a/t/52leaks.t +++ b/t/52leaks.t @@ -514,23 +514,7 @@ $ENV{PERL5LIB} = join ($Config::Config{path_sep}, @INC); ($ENV{PATH}) = $ENV{PATH} =~ /(.+)/; -my $persistence_tests = { - PPerl => { - cmd => [qw/pperl --prefork=1/, __FILE__], - }, - 'CGI::SpeedyCGI' => { - cmd => [qw/speedy -- -t5/, __FILE__], - }, -}; - -# scgi is smart and will auto-reap after -t amount of seconds -# pperl needs an actual killer :( -$persistence_tests->{PPerl}{termcmd} = [ - $persistence_tests->{PPerl}{cmd}[0], - '--kill', - @{$persistence_tests->{PPerl}{cmd}}[ 1 .. $#{$persistence_tests->{PPerl}{cmd}} ], -]; - +my $persistence_tests; SKIP: { skip 'Test already in a persistent loop', 1 if $ENV{DBICTEST_IN_PERSISTENT_ENV}; @@ -543,6 +527,23 @@ SKIP: { local $ENV{DBICTEST_IN_PERSISTENT_ENV} = 1; + $persistence_tests = { + PPerl => { + cmd => [qw/pperl --prefork=1/, __FILE__], + }, + 'CGI::SpeedyCGI' => { + cmd => [qw/speedy -- -t5/, __FILE__], + }, + }; + + # scgi is smart and will auto-reap after -t amount of seconds + # pperl needs an actual killer :( + $persistence_tests->{PPerl}{termcmd} = [ + $persistence_tests->{PPerl}{cmd}[0], + '--kill', + @{$persistence_tests->{PPerl}{cmd}}[ 1 .. $#{$persistence_tests->{PPerl}{cmd}} ], + ]; + require IPC::Open2; for my $type (keys %$persistence_tests) { SKIP: { @@ -591,10 +592,13 @@ done_testing; # just an extra precaution in case we blew away from the SKIP - since there are no # PID files to go by (man does pperl really suck :( END { - unless ($ENV{DBICTEST_IN_PERSISTENT_ENV}) { - close $_ for (*STDIN, *STDOUT, *STDERR); + if ($persistence_tests->{PPerl}{termcmd}) { local $?; # otherwise test will inherit $? of the system() - system (@{$persistence_tests->{PPerl}{termcmd}}) - if $persistence_tests->{PPerl}{termcmd}; + require IPC::Open3; + open my $null, ">", File::Spec->devnull; + waitpid( + IPC::Open3::open3(undef, $null, $null, @{$persistence_tests->{PPerl}{termcmd}}), + 0, + ); } }