[PECL-CVS] [pecl-networking-gearman] master: Missed a test
[email protected] (Rasmus Lerdorf) Sat, 4 Apr 2026 15:46:49 +0000
| Newsgroups | php.pecl.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Rasmus Lerdorf (rlerdorf)
Date: 2026-04-04T11:46:42-04:00
Commit: https://github.com/php/pecl-networking-gearman/commit/824b06ab218db2d9ce82c97dcd90dcf8fce643f8
Raw diff: https://github.com/php/pecl-networking-gearman/commit/824b06ab218db2d9ce82c97dcd90dcf8fce643f8.diff
Missed a test
Changed paths:
A tests/gearman_worker_integration_test_004.phpt
Diff:
diff --git a/tests/gearman_worker_integration_test_004.phpt b/tests/gearman_worker_integration_test_004.phpt
new file mode 100644
index 0000000..33aa6f4
--- /dev/null
+++ b/tests/gearman_worker_integration_test_004.phpt
@@ -0,0 +1,58 @@
+--TEST--
+Worker callback exception message is sent to gearmand (issue #21)
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnect.inc');
+?>
+--FILE--
+<?php
+require_once('connect.inc');
+
+$func = 'issue21_' . getmypid() . '_' . time();
+
+$wpid = pcntl_fork();
+if ($wpid === -1) {
+ die("FAIL: could not fork");
+}
+if ($wpid === 0) {
+ $w = new GearmanWorker();
+ if ($w->addServer($host, $port) !== true) exit(2);
+ $w->setTimeout(10000);
+ $w->addFunction($func, function($job) {
+ throw new RuntimeException("test exception message");
+ });
+ /* work() will propagate the exception after sending it to gearmand */
+ try {
+ $w->work();
+ } catch (\Throwable $e) {
+ /* expected */
+ }
+ exit(0);
+}
+
+usleep(200000);
+
+$received = null;
+
+$client = new GearmanClient();
+if ($client->addServer($host, $port) !== true) {
+ die("FAIL: could not add server");
+}
+$client->setExceptionCallback(function($task) use (&$received) {
+ $received = $task->data();
+ return GEARMAN_WORK_EXCEPTION;
+});
+
+$client->addTask($func, 'payload');
+$client->runTasks();
+
+pcntl_waitpid($wpid, $ws, 0);
+
+if ($received === "test exception message") {
+ echo "PASS" . PHP_EOL;
+} else {
+ echo "FAIL: received=" . var_export($received, true) . PHP_EOL;
+}
+--EXPECT--
+PASS