[PHP-CVS] [php-src] master: ext/pcntl: applied fixers to improve test robustness (#23037)
[email protected] (NickSdot via GitHub)
| Newsgroups | php.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-08-14T17:20:34+08:00
Commit: https://github.com/php/php-src/commit/a3a6c7793919fb4912b7358eaa33970af473d833
Raw diff: https://github.com/php/php-src/commit/a3a6c7793919fb4912b7358eaa33970af473d833.diff
ext/pcntl: applied fixers to improve test robustness (#23037)
Changed paths:
M ext/pcntl/tests/async_signals_2.phpt
M ext/pcntl/tests/bug81577.phpt
M ext/pcntl/tests/bug81577_2.phpt
M ext/pcntl/tests/bug81577_3.phpt
M ext/pcntl/tests/gh16769.phpt
M ext/pcntl/tests/pcntl_alarm_invalid_value.phpt
M ext/pcntl/tests/pcntl_exec_004.phpt
M ext/pcntl/tests/pcntl_getpriority_error.phpt
M ext/pcntl/tests/pcntl_setpriority_error.phpt
M ext/pcntl/tests/pcntl_signal.phpt
M ext/pcntl/tests/pcntl_signal_001.phpt
M ext/pcntl/tests/pcntl_signal_002.phpt
M ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt
M ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt
Diff:
diff --git a/ext/pcntl/tests/async_signals_2.phpt b/ext/pcntl/tests/async_signals_2.phpt
index 95a5a219768f..f94a8881ee09 100644
--- a/ext/pcntl/tests/async_signals_2.phpt
+++ b/ext/pcntl/tests/async_signals_2.phpt
@@ -22,9 +22,9 @@ try {
array_fill(0, 360, 0)
);
} catch (Exception $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
-Alarm!
+Exception: Alarm!
diff --git a/ext/pcntl/tests/bug81577.phpt b/ext/pcntl/tests/bug81577.phpt
index 7bf3b7ffea4d..557e719bd8ad 100644
--- a/ext/pcntl/tests/bug81577.phpt
+++ b/ext/pcntl/tests/bug81577.phpt
@@ -19,13 +19,13 @@ for ($i = 0; $i < 5; $i++) {
C::$a + C::$a;
posix_kill(posix_getpid(), SIGTERM) + C::$cond;
} catch (Throwable $ex) {
- echo get_class($ex) , " : " , $ex->getMessage() , "\n";
+ echo $ex::class, ': ', $ex->getMessage(), "\n";
}
}
?>
--EXPECT--
-Exception : Signal
-Exception : Signal
-Exception : Signal
-Exception : Signal
-Exception : Signal
+Exception: Signal
+Exception: Signal
+Exception: Signal
+Exception: Signal
+Exception: Signal
diff --git a/ext/pcntl/tests/bug81577_2.phpt b/ext/pcntl/tests/bug81577_2.phpt
index 2f92502df530..c77617dfb784 100644
--- a/ext/pcntl/tests/bug81577_2.phpt
+++ b/ext/pcntl/tests/bug81577_2.phpt
@@ -10,7 +10,7 @@ pcntl_signal(SIGTERM, function ($signo) {});
try {
$a = [1, posix_kill(posix_getpid(), SIGTERM), 2];
} catch (Throwable $ex) {
- echo get_class($ex) , " : " , $ex->getMessage() , "\n";
+ echo $ex::class, ': ', $ex->getMessage(), "\n";
}
var_dump($a);
?>
diff --git a/ext/pcntl/tests/bug81577_3.phpt b/ext/pcntl/tests/bug81577_3.phpt
index 1a30deaebaab..c50a04d68a47 100644
--- a/ext/pcntl/tests/bug81577_3.phpt
+++ b/ext/pcntl/tests/bug81577_3.phpt
@@ -12,8 +12,8 @@ pcntl_signal(SIGTERM, function ($signo) { throw new Exception("Signal"); });
try {
array_merge([1], [2]) + posix_kill(posix_getpid(), SIGTERM);
} catch (Throwable $ex) {
- echo get_class($ex) , " : " , $ex->getMessage() , "\n";
+ echo $ex::class, ': ', $ex->getMessage(), "\n";
}
?>
--EXPECT--
-Exception : Signal
+Exception: Signal
diff --git a/ext/pcntl/tests/gh16769.phpt b/ext/pcntl/tests/gh16769.phpt
index 60baee616101..5f9383882f86 100644
--- a/ext/pcntl/tests/gh16769.phpt
+++ b/ext/pcntl/tests/gh16769.phpt
@@ -11,8 +11,8 @@ $a[0] = &$a;
try {
pcntl_sigwaitinfo($a,$a);
} catch(\TypeError $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
-pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, array given
+TypeError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, array given
diff --git a/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt b/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt
index 59e74662f6f7..cc53a3ee04f8 100644
--- a/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt
+++ b/ext/pcntl/tests/pcntl_alarm_invalid_value.phpt
@@ -10,26 +10,26 @@ pcntl
try {
pcntl_alarm(-1);
} catch (\ValueError $e) {
- echo $e->getMessage() . \PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_alarm(PHP_INT_MIN);
} catch (\ValueError $e) {
- echo $e->getMessage() . \PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_alarm(PHP_INT_MAX);
} catch (\ValueError $e) {
- echo $e->getMessage() . \PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
var_dump(pcntl_alarm(0));
?>
--EXPECTF--
-pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d
-pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d
-pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d
+ValueError: pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d
+ValueError: pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d
+ValueError: pcntl_alarm(): Argument #1 ($seconds) must be between 0 and %d
int(0)
diff --git a/ext/pcntl/tests/pcntl_exec_004.phpt b/ext/pcntl/tests/pcntl_exec_004.phpt
index 270fdb755ca1..932a6a0277e7 100644
--- a/ext/pcntl/tests/pcntl_exec_004.phpt
+++ b/ext/pcntl/tests/pcntl_exec_004.phpt
@@ -11,15 +11,15 @@ if (!getenv("TEST_PHP_EXECUTABLE") || !is_executable(getenv("TEST_PHP_EXECUTABLE
try {
pcntl_exec(getenv("TEST_PHP_EXECUTABLE"), ['-n', new stdClass()]);
} catch (Error $error) {
- echo $error->getMessage() . "\n";
+ echo $error::class, ': ', $error->getMessage(), "\n";
}
try {
pcntl_exec(getenv("TEST_PHP_EXECUTABLE"), ['-n'], [new stdClass()]);
} catch (Error $error) {
- echo $error->getMessage() . "\n";
+ echo $error::class, ': ', $error->getMessage(), "\n";
}
?>
--EXPECT--
-Object of class stdClass could not be converted to string
-Object of class stdClass could not be converted to string
+Error: Object of class stdClass could not be converted to string
+Error: Object of class stdClass could not be converted to string
diff --git a/ext/pcntl/tests/pcntl_getpriority_error.phpt b/ext/pcntl/tests/pcntl_getpriority_error.phpt
index 2fa88a76842d..3ca9243dddfe 100644
--- a/ext/pcntl/tests/pcntl_getpriority_error.phpt
+++ b/ext/pcntl/tests/pcntl_getpriority_error.phpt
@@ -23,7 +23,7 @@ if (PHP_OS == "Darwin") {
try {
pcntl_getpriority(null, PRIO_PGRP + PRIO_USER + PRIO_PROCESS + 10);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
// Different behavior in MacOS than rest of operating systems
@@ -31,6 +31,6 @@ pcntl_getpriority(-1, PRIO_PROCESS);
?>
--EXPECTF--
-pcntl_getpriority(): Argument #2 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS
+ValueError: pcntl_getpriority(): Argument #2 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS
Warning: pcntl_getpriority(): Error %d: No process was located using the given parameters in %s
diff --git a/ext/pcntl/tests/pcntl_setpriority_error.phpt b/ext/pcntl/tests/pcntl_setpriority_error.phpt
index 6f0a67977a8f..1c40d747602b 100644
--- a/ext/pcntl/tests/pcntl_setpriority_error.phpt
+++ b/ext/pcntl/tests/pcntl_setpriority_error.phpt
@@ -23,13 +23,13 @@ if (PHP_OS == "Darwin") {
try {
$result = pcntl_setpriority(0, null, (PRIO_PGRP + PRIO_USER + PRIO_PROCESS + 10));
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
pcntl_setpriority(0, -123);
?>
--EXPECTF--
-pcntl_setpriority(): Argument #3 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS
+ValueError: pcntl_setpriority(): Argument #3 ($mode) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS
Warning: pcntl_setpriority(): Error 3: No process was located using the given parameters in %s
diff --git a/ext/pcntl/tests/pcntl_signal.phpt b/ext/pcntl/tests/pcntl_signal.phpt
index 2e65139e3937..f4ae1ef07e10 100644
--- a/ext/pcntl/tests/pcntl_signal.phpt
+++ b/ext/pcntl/tests/pcntl_signal.phpt
@@ -22,19 +22,19 @@ var_dump(pcntl_signal(SIGALRM, SIG_IGN));
try {
pcntl_signal(-1, -1);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
pcntl_signal(-1, function(){});
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
pcntl_signal(SIGALRM, "not callable");
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
/* test freeing queue in RSHUTDOWN */
@@ -45,7 +45,7 @@ echo "ok\n";
signal dispatched
got signal from %r\d+|nobody%r
bool(true)
-pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1
-pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1
-pcntl_signal(): Argument #2 ($handler) must be of type callable|int, string given
+ValueError: pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1
+ValueError: pcntl_signal(): Argument #1 ($signal) must be greater than or equal to 1
+TypeError: pcntl_signal(): Argument #2 ($handler) must be of type callable|int, string given
ok
diff --git a/ext/pcntl/tests/pcntl_signal_001.phpt b/ext/pcntl/tests/pcntl_signal_001.phpt
index 2f4f385553a2..0b9a0f1d3577 100644
--- a/ext/pcntl/tests/pcntl_signal_001.phpt
+++ b/ext/pcntl/tests/pcntl_signal_001.phpt
@@ -9,8 +9,8 @@ try {
echo "signaled\n";
});
} catch (Error $e) {
- echo $e->getMessage();
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
-pcntl_signal(): Argument #1 ($signal) must be less than %d
+ValueError: pcntl_signal(): Argument #1 ($signal) must be less than %d
diff --git a/ext/pcntl/tests/pcntl_signal_002.phpt b/ext/pcntl/tests/pcntl_signal_002.phpt
index 1d4e29d94a75..f98392205e21 100644
--- a/ext/pcntl/tests/pcntl_signal_002.phpt
+++ b/ext/pcntl/tests/pcntl_signal_002.phpt
@@ -8,9 +8,9 @@ pcntl
try {
pcntl_signal(SIGTERM, -1);
} catch (Error $error) {
- echo $error->getMessage();
+ echo $error::class, ': ', $error->getMessage(), PHP_EOL;
}
?>
--EXPECT--
-pcntl_signal(): Argument #2 ($handler) must be either SIG_DFL or SIG_IGN when an integer value is given
+ValueError: pcntl_signal(): Argument #2 ($handler) must be either SIG_DFL or SIG_IGN when an integer value is given
diff --git a/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt b/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt
index 06c4f827c6ef..1558b7556d21 100644
--- a/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt
+++ b/ext/pcntl/tests/pcntl_signal_dispatch_exception.phpt
@@ -23,12 +23,12 @@ posix_kill(posix_getpid(), SIGUSR2);
try {
pcntl_signal_dispatch();
} catch (\Exception $e) {
- echo $e->getMessage() . "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "Handlers called: " . implode(', ', $called) . "\n";
?>
--EXPECT--
-Exception in signal handler
+Exception: Exception in signal handler
Handlers called: SIGUSR1
diff --git a/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt b/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt
index e61b17bf3fbd..bd7e22e6634a 100644
--- a/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt
+++ b/ext/pcntl/tests/pcntl_signal_functions_invalid_signals.phpt
@@ -16,65 +16,65 @@ max_execution_time=0
try {
pcntl_sigprocmask(SIG_BLOCK, ["not_a_signal"]);
} catch (TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigprocmask(SIG_BLOCK, [0]);
} catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigprocmask(SIG_BLOCK, []);
} catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigwaitinfo(["not_a_signal"]);
} catch (TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigwaitinfo([0]);
} catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigwaitinfo([]);
} catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigtimedwait(["not_a_signal"], $info, 1);
} catch (TypeError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigtimedwait([0], $info, 1);
} catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
pcntl_sigtimedwait([], $info, 1);
} catch (ValueError $e) {
- echo $e->getMessage() . PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
-pcntl_sigprocmask(): Argument #2 ($signals) signals must be of type int, string given
-pcntl_sigprocmask(): Argument #2 ($signals) signals must be between 1 and %d
-pcntl_sigprocmask(): Argument #2 ($signals) must not be empty
-pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, string given
-pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be between 1 and %d
-pcntl_sigwaitinfo(): Argument #1 ($signals) must not be empty
-pcntl_sigtimedwait(): Argument #1 ($signals) signals must be of type int, string given
-pcntl_sigtimedwait(): Argument #1 ($signals) signals must be between 1 and %d
-pcntl_sigtimedwait(): Argument #1 ($signals) must not be empty
+TypeError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be of type int, string given
+ValueError: pcntl_sigprocmask(): Argument #2 ($signals) signals must be between 1 and %d
+ValueError: pcntl_sigprocmask(): Argument #2 ($signals) must not be empty
+TypeError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, string given
+ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be between 1 and %d
+ValueError: pcntl_sigwaitinfo(): Argument #1 ($signals) must not be empty
+TypeError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be of type int, string given
+ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) signals must be between 1 and %d
+ValueError: pcntl_sigtimedwait(): Argument #1 ($signals) must not be empty