Skip to content

Commit 0b1e401

Browse files
committed
Skip tests calling wmic if it is not available
The WMIC utitlity is deprecated as of Windows 10 21H1, and a feature on demand which is enabled by default in Windows 11 22H2 and 23H2, but will be disabled by default in the next release of Windows.[1] Therefore, we ensure that tests which rely on wmic.exe are properly skipped if it is not available. [1] <https://learn.microsoft.com/en-us/windows/whats-new/deprecated-features#deprecated-features> Closes phpGH-15583.
1 parent 2bb5dea commit 0b1e401

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Zend/tests/bug55509.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ elseif (PHP_OS == 'FreeBSD') {
4949
die('skip Not enough memory.');
5050
}
5151
} elseif (PHP_OS == "WINNT") {
52-
$s = trim(shell_exec("wmic OS get FreeVirtualMemory /Value 2>nul"));
53-
$freeMemory = explode('=', $s)[1]*1;
52+
$s = shell_exec("wmic OS get FreeVirtualMemory /Value 2>nul");
53+
if (!$s) {
54+
die('skip wmic not available');
55+
}
56+
$freeMemory = explode('=', trim($s))[1]*1;
5457

5558
if ($freeMemory < 2.1*1024*1024) {
5659
die('skip Not enough memory.');

ext/standard/tests/general_functions/proc_nice_basic-win.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ if (!defined('PHP_WINDOWS_VERSION_MAJOR')) {
1111
if (getenv('SKIP_SLOW_TESTS')) {
1212
die('skip: Slow test');
1313
}
14+
15+
if (!shell_exec("where wmic 2>nul")) {
16+
die('skip wmic not available');
17+
}
1418
?>
1519
--FILE--
1620
<?php

0 commit comments

Comments
 (0)