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 ------------------------------------