In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/802cb175567cf176ce9735ceaa7afb023e44506e?hp=897340598920cdabb9c0638e4c3d777bf424ad97>
- Log ----------------------------------------------------------------- commit 802cb175567cf176ce9735ceaa7afb023e44506e Author: Rafael Garcia-Suarez <[email protected]> Date: Sun Jul 4 13:31:57 2010 +0200 Make previous test fix conditional on the platform being Windows M t/io/openpid.t commit 5732108f035c123424964e9a1a8850d4c1033102 Author: George Greer <[email protected]> Date: Sun Jul 4 01:20:53 2010 -0400 Force t/io/openpid.t to use the alarm() watchdog strategy. * The default watchdog strategy on Win32 doesn't work because the watchdog is executed via subshell ("cmd /c perl -e '...'"). When the test finishes and tries to kill the watchdog all it manages to do is whack cmd.exe and the watchdog still fires, potentially killing an innocent process. * Trying to use the fork() strategy instead causes openpid.t's test #9's "ok" to be lost occasionally. The message itself is generated by the 4th child of the test and should go directly to stdout, but sometimes the output vanishes for unexplained reasons. This doesn't appear to happen without the watchdog enabled. * Using the alarm() watchdog strategy seems to not cause any badness. M t/io/openpid.t M t/test.pl ----------------------------------------------------------------------- Summary of changes: t/io/openpid.t | 2 +- t/test.pl | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 t/io/openpid.t mode change 100644 => 100755 t/test.pl diff --git a/t/io/openpid.t b/t/io/openpid.t old mode 100644 new mode 100755 index ee4702c..946fa5e --- a/t/io/openpid.t +++ b/t/io/openpid.t @@ -18,7 +18,7 @@ if ($^O eq 'dos') { } plan tests => 10; -watchdog(15); +watchdog(15, $^O eq 'MSWin32' ? "alarm" : ''); use Config; $| = 1; diff --git a/t/test.pl b/t/test.pl old mode 100644 new mode 100755 index 6109d8e..c43c275 --- a/t/test.pl +++ b/t/test.pl @@ -809,9 +809,10 @@ WHOA # Set a watchdog to timeout the entire test file # NOTE: If the test file uses 'threads', then call the watchdog() function # _AFTER_ the 'threads' module is loaded. -sub watchdog ($) +sub watchdog ($;$) { my $timeout = shift; + my $method = shift; my $timeout_msg = 'Test process timed out - terminating'; # Valgrind slows perl way down so give it more time before dying. @@ -819,6 +820,10 @@ sub watchdog ($) my $pid_to_kill = $$; # PID for this process + if ($method eq "alarm") { + goto WATCHDOG_VIA_ALARM; + } + # Don't use a watchdog process if 'threads' is loaded - # use a watchdog thread instead if (! $threads::threads) { @@ -925,6 +930,7 @@ sub watchdog ($) } # If everything above fails, then just use an alarm timeout +WATCHDOG_VIA_ALARM: if (eval { alarm($timeout); 1; }) { # Load POSIX if available eval { require POSIX; }; -- Perl5 Master Repository
