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-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7617dcc477b643c32c043b68e0c6fdcbc7ec5ebb;p=dbsrgits%2FDBIx-Class-Historic.git Keep T::B IO open in t/52leaks.t END - other ENDs pending (esp. since 961d79db) Read under -w --- diff --git a/t/52leaks.t b/t/52leaks.t index 6039205..95e8bd0 100644 --- a/t/52leaks.t +++ b/t/52leaks.t @@ -536,23 +536,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}; @@ -562,6 +546,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: { @@ -610,10 +611,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, + ); } }