cvs: php4 / run-tests.php
| From: | Wez Furlong | Date: | Sat, 15 Feb 2003 18:09:52 +0000 |
| Subject: | cvs: php4 / run-tests.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-18854@lists.php.net to get a copy of this message | ||
wez Sat Feb 15 13:09:52 2003 EDT
Modified files:
/php4 run-tests.php
Log:
If a test does not have any data after 60 seconds of waiting, assume that
it died a horrible death and kill it.
This is useful on windows when a message box is popped-up during an automated
test-run.
Index: php4/run-tests.php
diff -u php4/run-tests.php:1.142 php4/run-tests.php:1.143
--- php4/run-tests.php:1.142 Mon Feb 3 07:14:13 2003
+++ php4/run-tests.php Sat Feb 15 13:09:52 2003
@@ -516,6 +516,40 @@
}
}
+function system_with_timeout($commandline)
+{
+ $data = "";
+
+ $proc = proc_open($commandline, array(1 => array('pipe', 'w')), $pipes);
+
+ if (!$proc)
+ return false;
+
+ while (true) {
+ /* hide errors from interrupted syscalls */
+ $r = $pipes;
+ $w = null;
+ $e = null;
+ $n = stream_select($r, $w, $e, 60);
+
+ if ($n == 0) {
+ /* timed out */
+ $data .= "\n ** ERROR: process timed out **\n";
+ proc_terminate($proc);
+ return $data;
+ } else if ($n) {
+ $line = fgets($pipes[1]);
+ if ($line === false) {
+ /* EOF */
+ break;
+ }
+ $data .= $line;
+ }
+ }
+ $code = proc_close($proc);
+ return $data;
+}
+
//
// Run an individual test case.
//
@@ -667,7 +701,8 @@
COMMAND $cmd
";
- $out =
$cmd;
+// $out = $cmd;
+ $out = system_with_timeout($cmd);
@unlink($tmp_post);