From 61bfdcfaf922094ab70a4a7fde94dfba95956424 Mon Sep 17 00:00:00 2001 From: jknapp Date: Wed, 5 Aug 2026 13:06:23 -0700 Subject: [PATCH] test(cac-path-parity): run the .phpt suite as a build gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing executed ext/cac-path-parity/tests/ — not Dockerfile.lsphp, not .gitea/workflows/build-push.yaml. The suite passed, but as shipped it was documentation, not a gate. `make test` now runs in the ext-build stage, against the same lsphp build the .so ships next to. It costs ~1s per PHP version. The lsphp packages turn out to include a real CLI binary (php-config --php-binary => /usr/local/lsws/lsphpNN/bin/phpN.N), so run-tests.php works with no extra tooling. Guarded twice, because `make test` fails silently by default: - if PHP_EXECUTABLE is missing, the Makefile prints "Cannot run tests without CLI sapi." and EXITS 0. Asserted rather than assumed. - a run that executes zero tests also exits 0, so the summary is checked against the number of .phpt files on disk, plus "Tests failed : 0". Same reasoning as the `lsphp -i` probe: an assertion that cannot fail is worse than no assertion. Verified 8/8 on PHP 8.1/8.3/8.5. Mutation-tested both guards: breaking 001-rewrite.phpt's expectation fails the build ("FATAL: cac_path_parity .phpt suite FAILED"); adding a test that always SKIPs makes run-tests.php still exit 0 but the build fails on "expected all 9 .phpt tests to run" (summary read "Number of tests : 9 8"). Co-Authored-By: Claude Opus 5 (1M context) --- Dockerfile.lsphp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Dockerfile.lsphp b/Dockerfile.lsphp index 16420d6..9171365 100644 --- a/Dockerfile.lsphp +++ b/Dockerfile.lsphp @@ -76,6 +76,20 @@ RUN set -e; \ printf '%s' "$RTV" > /build-out/lsphp.version; \ echo "cac_path_parity will be compiled against lsphp${PHPVER} $RTV" +## Build, then RUN THE .phpt SUITE as a build gate. Before this, ext/…/tests/ +## existed but nothing ever executed it — neither this Dockerfile nor +## .gitea/workflows/build-push.yaml — so six green tests were documentation. It +## costs ~1s per PHP version and it runs against the SAME lsphp build the .so +## will ship next to. +## +## Two guards around `make test`, because its default failure mode is silence: +## - if PHP_EXECUTABLE is missing the Makefile prints "Cannot run tests without +## CLI sapi." and EXITS 0. The lsphp packages do ship a real CLI +## (php-config --php-binary => .../bin/phpN.N), but assert it rather than +## trusting it. +## - a run that executes ZERO tests also exits 0, so assert the summary shows +## every .phpt in the directory both ran and passed. Same reasoning as the +## `lsphp -i` probe below: an assertion that cannot fail is worse than none. COPY ./ext/cac-path-parity /usr/src/cac-path-parity RUN set -e; \ cd /usr/src/cac-path-parity; \ @@ -83,6 +97,29 @@ RUN set -e; \ ./configure --enable-cac-path-parity \ --with-php-config=/usr/local/lsws/lsphp${PHPVER}/bin/php-config; \ make -j"$(nproc)"; \ + PHP_BIN=$(/usr/local/lsws/lsphp${PHPVER}/bin/php-config --php-binary); \ + if [ ! -x "$PHP_BIN" ]; then \ + echo "FATAL: no CLI php at '$PHP_BIN' — \`make test\` would print" >&2; \ + echo " 'Cannot run tests without CLI sapi.' and exit 0." >&2; \ + exit 1; \ + fi; \ + EXPECTED=$(ls tests/*.phpt | wc -l); \ + if [ "$EXPECTED" -lt 1 ]; then echo "FATAL: no .phpt tests found" >&2; exit 1; fi; \ + if ! NO_INTERACTION=1 REPORT_EXIT_STATUS=1 make test >/tmp/make-test.log 2>&1; then \ + cat /tmp/make-test.log >&2; \ + echo "FATAL: cac_path_parity .phpt suite FAILED — not shipping this .so." >&2; \ + exit 1; \ + fi; \ + cat /tmp/make-test.log; \ + if ! grep -Eq "^Number of tests : +${EXPECTED} +${EXPECTED} *$" /tmp/make-test.log; then \ + echo "FATAL: expected all ${EXPECTED} .phpt tests to run; the summary above disagrees." >&2; \ + exit 1; \ + fi; \ + if ! grep -Eq "^Tests failed +: +0 " /tmp/make-test.log; then \ + echo "FATAL: run-tests.php reported failures." >&2; \ + exit 1; \ + fi; \ + echo "cac_path_parity: ${EXPECTED}/${EXPECTED} .phpt tests passed"; \ cp modules/cac_path_parity.so /build-out/ ## ---- stage 2: the shipped sidecar image ------------------------------------