From 7776216290181f102b55bb7fb053b9b5de0014af Mon Sep 17 00:00:00 2001 From: Edmond <1571649+EdmondDantes@users.noreply.github.com> Date: Fri, 5 Jun 2026 12:43:22 +0300 Subject: [PATCH 1/2] test(windows): split static/016 + skip POSIX-CLI compression tests on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit static/016-static-handler-validation: split OS-agnostic argument/setter validation (runs everywhere) from the POSIX-only filesystem-root cases. The "/"-as-root rejection and leading-slash-is-absolute semantics move to a new 016-...-posix companion (SKIPIF non-Windows). The cross-platform test feeds an absolute temp path for the missing-root case and accepts a drive-letter root in the happy path. Product behaviour is already correct on Windows — this only makes the test platform-aware (no %s muting; coverage preserved on both). compression/010,012,030,070: these verify gzip by piping the response through a POSIX gzip/gunzip CLI via proc_open, which pipe-deadlocks against the Git-for-Windows binaries. Skip on Windows with a documented reason. Previously they BORKed because the SKIPIF probed with the bash builtin `command -v`, which isn't a cmd.exe command, so the SKIPIF emitted invalid output. Still run on POSIX CI. --- .../compression/010-h1-buffered-gzip.phpt | 3 +- .../compression/012-h1-streaming-gzip.phpt | 3 +- .../compression/030-h1-request-gzip-in.phpt | 3 +- .../compression/070-encoder-pool-reuse.phpt | 3 +- .../016-static-handler-validation-posix.phpt | 50 +++++++++++++++++++ .../static/016-static-handler-validation.phpt | 15 ++++-- 6 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 tests/phpt/server/static/016-static-handler-validation-posix.phpt diff --git a/tests/phpt/server/compression/010-h1-buffered-gzip.phpt b/tests/phpt/server/compression/010-h1-buffered-gzip.phpt index 36e7322..817b24f 100644 --- a/tests/phpt/server/compression/010-h1-buffered-gzip.phpt +++ b/tests/phpt/server/compression/010-h1-buffered-gzip.phpt @@ -6,7 +6,8 @@ true_async --SKIPIF-- /dev/null')) === '') die('skip gunzip(1) not in PATH'); ?> --FILE-- /dev/null')) === '') die('skip gunzip(1) not in PATH'); ?> --FILE-- /dev/null')) === '') die('skip gzip(1) not in PATH'); ?> --FILE-- /dev/null')) === '') die('skip gunzip(1) not in PATH'); ?> --FILE-- +--FILE-- +getMessage(), "\n"; + } +} + +/* "/" resolves to the filesystem root → explicit guard. */ +check('ctor:root-slash', fn() => new StaticHandler('/x/', '/')); + +/* Leading slash is absolute on POSIX → a missing one reaches not-found + * (proving it cleared the absolute-path gate, unlike on Windows). */ +check('ctor:root-missing-abs', fn() => new StaticHandler('/x/', '/nonexistent-' . bin2hex(random_bytes(8)))); + +echo "done\n"; +?> +--EXPECTF-- +ctor:root-slash: TrueAsync\HttpServerInvalidArgumentException: StaticHandler root directory must not be '/' +ctor:root-missing-abs: TrueAsync\HttpServerInvalidArgumentException: StaticHandler root directory not found: %s +done diff --git a/tests/phpt/server/static/016-static-handler-validation.phpt b/tests/phpt/server/static/016-static-handler-validation.phpt index 87e1d6d..1fec6f2 100644 --- a/tests/phpt/server/static/016-static-handler-validation.phpt +++ b/tests/phpt/server/static/016-static-handler-validation.phpt @@ -45,15 +45,23 @@ check('ctor:prefix-double-slash', fn() => new StaticHandler('/a//b/', $root)); check('ctor:prefix-too-short', fn() => new StaticHandler('/', $root)); // len < 2 /* ---- Constructor: root-directory validation -------------------- */ +/* Cross-platform: feed an absolute-but-missing path under the system + * temp dir so it clears the absolute-path gate and hits the not-found + * branch on every OS (a bare "/..." path is NOT absolute on Windows). + * The POSIX-only root cases ("/" itself) live in 016-...-posix. */ +$absent_root = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'sh-absent-' . bin2hex(random_bytes(8)); check('ctor:root-empty', fn() => new StaticHandler('/x/', '')); check('ctor:root-relative', fn() => new StaticHandler('/x/', 'relative')); -check('ctor:root-missing', fn() => new StaticHandler('/x/', '/nonexistent-' . bin2hex(random_bytes(8)))); +check('ctor:root-missing', fn() => new StaticHandler('/x/', $absent_root)); check('ctor:root-not-a-dir', fn() => new StaticHandler('/x/', __FILE__)); -check('ctor:root-slash', fn() => new StaticHandler('/x/', '/')); /* ---- Happy path ------------------------------------------------ */ $sh = new StaticHandler('/static/', $root); -echo "happy-path: prefix=", $sh->getUrlPrefix(), " root-ok=", str_starts_with($sh->getRootDirectory(), '/') ? 'yes' : 'no', "\n"; +$gr = $sh->getRootDirectory(); +/* "absolute for this OS": leading slash on *nix, drive-letter / UNC on Windows. */ +$root_abs = $gr !== '' && (str_starts_with($gr, '/') || str_starts_with($gr, '\\') + || (strlen($gr) >= 2 && ctype_alpha($gr[0]) && $gr[1] === ':')); +echo "happy-path: prefix=", $sh->getUrlPrefix(), " root-ok=", $root_abs ? 'yes' : 'no', "\n"; echo "isLocked: ", $sh->isLocked() ? 'yes' : 'no', "\n"; /* ---- setIndexFiles: validation arms --------------------------- */ @@ -136,7 +144,6 @@ ctor:root-empty: TrueAsync\HttpServerInvalidArgumentException: StaticHandler roo ctor:root-relative: TrueAsync\HttpServerInvalidArgumentException: StaticHandler root directory must be an absolute path ctor:root-missing: TrueAsync\HttpServerInvalidArgumentException: StaticHandler root directory not found: %s ctor:root-not-a-dir: TrueAsync\HttpServerInvalidArgumentException: StaticHandler root directory is not a directory: %s -ctor:root-slash: TrueAsync\HttpServerInvalidArgumentException: StaticHandler root directory must not be '/' happy-path: prefix=/static/ root-ok=yes isLocked: no idx:non-string: TrueAsync\HttpServerInvalidArgumentException: StaticHandler index files must be strings From 46391f70850dc8188ab24516459142584493fb00 Mon Sep 17 00:00:00 2001 From: Edmond <1571649+EdmondDantes@users.noreply.github.com> Date: Fri, 5 Jun 2026 12:58:26 +0300 Subject: [PATCH 2/2] ci(windows): pin Windows deps series to 8.5 (vs17) for the 8.6 dev tip WINDOWS_X64_ZTS_RELEASE failed resolving SDK dependencies: SDK\Exception: The passed CRT 'vs17' doesn't match any available for branch '8.6' php.net's deps server now ships the dev tip (branches "8.6" and "master") only for the vs18 / VS 2026 toolchain; the newest series that still carries vs17 deps is 8.5. The windows-2022 runner is vs17, so the 8.6 dev tip must build against the 8.5 vs17 dep series -- the libs (openssl, libxml2, ...) track the toolchain, not the PHP minor, and vs17 builds 8.6 fine locally. find-target-branch.bat previously derived "8." from php_version.h and remapped a hardcoded "8.5" -> "master"; that broke when php-src bumped to 8.6 and the dev-tip deps moved to vs18. Pin the series to 8.5 (with a note to bump or move to vs18 later). --- .../scripts/windows/find-target-branch.bat | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/scripts/windows/find-target-branch.bat b/.github/scripts/windows/find-target-branch.bat index 89652bc..bac6c8b 100644 --- a/.github/scripts/windows/find-target-branch.bat +++ b/.github/scripts/windows/find-target-branch.bat @@ -1,8 +1,18 @@ @echo off -for /f "usebackq tokens=3" %%i in (`findstr PHP_MAJOR_VERSION main\php_version.h`) do set BRANCH=%%i -for /f "usebackq tokens=3" %%i in (`findstr PHP_MINOR_VERSION main\php_version.h`) do set BRANCH=%BRANCH%.%%i - -if /i "%BRANCH%" equ "8.5" ( - set BRANCH=master -) +rem Pin the PHP SDK dependency series to 8.5 (vs17). +rem +rem We build php-src's dev tip (true-async == 8.6-dev) on the windows-2022 +rem runner, i.e. the vs17 / VS 2022 toolchain. php.net's deps server only +rem publishes the bleeding edge (branches "8.6" and "master") for the vs18 / +rem VS 2026 toolchain -- there is no vs17 build of those. The newest series +rem that ships vs17 dependencies is 8.5, and those libs (openssl, libxml2, +rem ...) build the 8.6 tip fine: the series tracks the toolchain, not the PHP +rem minor. Asking for "8.6"/"master" under --crt vs17 fails with +rem "CRT 'vs17' doesn't match any available for branch ...". +rem +rem Bump this to 8.6 once php.net publishes packages-8.6-vs17-*, or switch the +rem runner+PHP_BUILD_CRT to vs18 to follow the dev-tip deps directly. +rem (Old logic derived "8." and remapped a hardcoded 8.5 -> master; +rem it broke when php-src went 8.6 and the dev deps moved to vs18.) +set BRANCH=8.5