Repository navigation
Tests: Skip local HTTP fixtures when a host declares loopback listening is restricted - #16183
lancewillett wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the opt-in handling of loopback port reservation failures.
No open issues 🎉
What changed in this PR
Adds an opt-in setting for restricted test hosts to skip HTTP transport tests that require a local fixture server when PHP cannot reserve a loopback port.
Changes:
- Honors
WP_TESTS_SKIP_HTTP_LOOPBACK=1only when port reservation fails. - Preserves normal test execution and startup failures when a port is reserved.
- Documents the setting and its limited scope.
| File | Description |
|---|---|
tests/phpunit/tests/http/base.php |
Sets the fixture skip reason when port reservation fails and the setting is enabled. |
tests/phpunit/README.md |
Documents how restricted hosts can enable the setting. |
Review effort: Balanced
The cURL and streams tests start a local PHP server. On hosting reporters that prohibit listening on a loopback port, the same setup failure appears 48 times. PHP can report error number zero and an empty message, so the suite cannot reliably infer the host’s policy from the error.
This lets a host set
WP_TESTS_SKIP_HTTP_LOOPBACK=1in the environment where PHPUnit runs. The setting takes effect only if PHP fails to reserve a port. The existing fixture checks then skip the cases that need the server. Other transport tests still run. A server that gets a port but never answers still fails, including with the setting enabled.Testing
Ran the existing cURL and streams classes using PHP 8.3, PHPUnit 9.6 and random-order seed 66794. With binding denied by the macOS sandbox, trunk reported 48 failures. With this patch and the setting enabled, 48 tests skipped and the four independent cases passed on both single-site and multisite. Leaving the setting unset preserved all 48 failures.
With listening allowed, all 52 tests passed with 122 assertions both on trunk and with the patch and setting enabled. PHP syntax and PHPCS checks passed.
Separately allowed binding but blocked connections to the fixture. A redirect test for each transport still failed with the five-second readiness diagnostic. This exercises the timeout path locally. The cause of the timeouts on GoDaddy and Hostinger is still open.
Feedback from a run on a restricted hosting reporter would be welcome.
Trac ticket: https://core.trac.wordpress.org/ticket/66794