Skip to content

Commit 0a34716

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 46929ea + fe30c50 commit 0a34716

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

sapi/fpm/tests/socket-close-on-exec.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FPM: Set CLOEXEC on the listen and connection socket
33
--SKIPIF--
44
<?php
55
require_once "skipif.inc";
6-
FPM\Tester::skipIfShellCommandFails('lsof -v 2> /dev/null');
6+
FPM\Tester::skipIfShellCommandFails('lsof -v', 'lsof-org/lsof');
77
?>
88
--FILE--
99
<?php

sapi/fpm/tests/tester.inc

+16-4
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,24 @@ class Tester
342342
* Skip test if supplied shell command fails.
343343
*
344344
* @param string $command
345+
* @param string|null $expectedPartOfOutput
345346
*/
346-
static public function skipIfShellCommandFails($command)
347+
static public function skipIfShellCommandFails(string $command, string $expectedPartOfOutput = null)
347348
{
348-
$output = system($command, $code);
349-
if ($code) {
350-
die("skip command '$command' faield with code $code and output: $output");
349+
$result = exec("$command 2>&1", $output, $code);
350+
if ($result === false || $code) {
351+
die("skip command '$command' faieled with code $code");
352+
}
353+
if (!is_null($expectedPartOfOutput)) {
354+
if (is_array($output)) {
355+
foreach ($output as $line) {
356+
if (str_contains($line, $expectedPartOfOutput)) {
357+
// string found so no need to skip
358+
return;
359+
}
360+
}
361+
}
362+
die("skip command '$command' did not contain output '$expectedPartOfOutput'");
351363
}
352364
}
353365

0 commit comments

Comments
 (0)