From 6b23f4b34ac066d254a86b65da918bb2b8f45b3d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 1 Aug 2025 01:53:38 +0800 Subject: [PATCH] Fix PHPUnit test on Windows, ignore calling linux system util for other OS --- src/SPC/util/SPCTarget.php | 7 +++++-- tests/SPC/util/PkgConfigUtilTest.php | 4 ++++ tests/SPC/util/SPCConfigUtilTest.php | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/SPC/util/SPCTarget.php b/src/SPC/util/SPCTarget.php index d4164ceb..c6519a9a 100644 --- a/src/SPC/util/SPCTarget.php +++ b/src/SPC/util/SPCTarget.php @@ -99,8 +99,11 @@ class SPCTarget */ public static function getLibcVersion(): ?string { - $libc = self::getLibc(); - return SystemUtil::getLibcVersionIfExists($libc); + if (PHP_OS_FAMILY === 'Linux') { + $libc = self::getLibc(); + return SystemUtil::getLibcVersionIfExists($libc); + } + return null; } /** diff --git a/tests/SPC/util/PkgConfigUtilTest.php b/tests/SPC/util/PkgConfigUtilTest.php index 6d8988fd..64882a54 100644 --- a/tests/SPC/util/PkgConfigUtilTest.php +++ b/tests/SPC/util/PkgConfigUtilTest.php @@ -19,6 +19,10 @@ final class PkgConfigUtilTest extends TestCase public static function setUpBeforeClass(): void { + if (PHP_OS_FAMILY === 'Windows') { + // Skip tests on Windows as pkg-config is not typically available + self::markTestSkipped('PkgConfigUtil tests are not applicable on Windows.'); + } parent::setUpBeforeClass(); // Save original PATH diff --git a/tests/SPC/util/SPCConfigUtilTest.php b/tests/SPC/util/SPCConfigUtilTest.php index 7b8baa6c..0c0fbc7e 100644 --- a/tests/SPC/util/SPCConfigUtilTest.php +++ b/tests/SPC/util/SPCConfigUtilTest.php @@ -21,6 +21,10 @@ class SPCConfigUtilTest extends TestCase */ public static function setUpBeforeClass(): void { + if (PHP_OS_FAMILY === 'Windows') { + // Skip tests on Windows as SPCConfigUtil is not applicable + self::markTestSkipped('SPCConfigUtil tests are not applicable on Windows.'); + } $testdir = WORKING_DIR . '/.configtest'; FileSystem::createDir($testdir); FileSystem::writeFile($testdir . '/lib.json', file_get_contents(ROOT_DIR . '/config/lib.json'));