Merge branch 'PHP-8.3'

This commit is contained in:
Jakub Zelenka 2023-08-30 14:30:06 +01:00
commit 0a34716667
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
2 changed files with 17 additions and 5 deletions

View file

@ -3,7 +3,7 @@ FPM: Set CLOEXEC on the listen and connection socket
--SKIPIF-- --SKIPIF--
<?php <?php
require_once "skipif.inc"; require_once "skipif.inc";
FPM\Tester::skipIfShellCommandFails('lsof -v 2> /dev/null'); FPM\Tester::skipIfShellCommandFails('lsof -v', 'lsof-org/lsof');
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -342,12 +342,24 @@ class Tester
* Skip test if supplied shell command fails. * Skip test if supplied shell command fails.
* *
* @param string $command * @param string $command
* @param string|null $expectedPartOfOutput
*/ */
static public function skipIfShellCommandFails($command) static public function skipIfShellCommandFails(string $command, string $expectedPartOfOutput = null)
{ {
$output = system($command, $code); $result = exec("$command 2>&1", $output, $code);
if ($code) { if ($result === false || $code) {
die("skip command '$command' faield with code $code and output: $output"); die("skip command '$command' faieled with code $code");
}
if (!is_null($expectedPartOfOutput)) {
if (is_array($output)) {
foreach ($output as $line) {
if (str_contains($line, $expectedPartOfOutput)) {
// string found so no need to skip
return;
}
}
}
die("skip command '$command' did not contain output '$expectedPartOfOutput'");
} }
} }