Include the test helper once in every test that loads it - #309
Merged
Conversation
Tests: - The shared helper declares class TestCase at file level, and a persistent worker keeps its class table between requests, so a test that pulls it in with a bare `require` fatals on the second request one worker serves — reported as HTTP 500 with a non-JSON body naming the wrong test. Nothing running in a worker profile still did this, so the sweep closes the trap ahead of the next test moved into one rather than fixing a live failure. - Three fixtures outside tests/php load the same helper by a different path depth, which is why an earlier count missed them. 234 test files changed (no new tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests/php/test_helper.phpdeclares classTestCaseat file level. A persistent PHP worker keeps its class table between requests, so a test that pulls the helper in with a barerequirefatals on the second request one worker serves:The runner sees a non-JSON body and reports
HTTP 500against whichever test drew that worker, so the failure names the wrong culprit and moves from run to run.This replaces
requirewithrequire_oncein the 234 places that load the helper.Not a fix for a live failure
Nothing currently running in a worker-mode profile still used the bare form — all 142 suite entries of the seven profiles that set
WORKER_FILE(worker,hooks,hooksdb,fibers,breaker,revolt,revoltclassic) were already onrequire_once. What this closes is the trap: 234 files carried a form that would fatal the moment one of them is moved into a worker suite, which happens routinely, and would misreport when it did.Three of the 234 live outside
tests/php/(fixtures/framework/index.php,fixtures/php_deny/public/index.php,fixtures/php_deny/public/_security/denied.php). They load the same helper by a different path depth, which is why a grep scoped totests/php/missed them.Deliberate bare includes are untouched — in particular
tests/php/breaker/test_breaker_shutdown_dtor_fatal.php, whose barerequireofbreaker_redeclare.phpexists to trigger exactly this fatal.Verification
Both sides observed on the
hooksprofile (PHP_WORKERS: "1"plusWORKER_FILE, so consecutive requests provably land on one worker). Test files are volume-mounted, so neither side needed an image build.Before, three requests to one swept test:
After, five requests, the last two to a different swept file on the same worker — so this also covers the converse, that a class declared by the first test stays visible to a later one rather than merely not being re-declared:
Full suite before and after, 30 profiles: 635 passed / 0 failed / 1 error (636) both times, with byte-identical counts in every profile. The single error is
shared/test_channel_async_usevar_stress, a known flake unrelated to this change. The five profiles that consume the fixture files were re-run separately after those three were swept and match their baselines (7 / 3 / 1 / 1 / 1, all passing).Host checks:
cargo fmt -- --checkclean,cargo clippy --no-default-features -- -D warningsexit 0,cargo test --no-default-features955+ passed / 0 failed. No Rust source is touched.Follow-ups filed separately
TestCase::__constructinstallsset_error_handlerandset_exception_handleron every request and removes neither. Under a persistent worker both stacks grow one entry per request — measured at 2, 50 and 500 requests, giving depth 2, 50 and 500, roughly 1.7 KB per request held for the worker's lifetime.register_shutdown_functiondoes not accumulate: five registering requests produced five shutdown runs, not fifteen. This predates the sweep and is untouched by it.tests/php/worker/justify their echo style with a comment saying the helper is pulled in by a barerequire. That stopped being true earlier and is now false everywhere, so it reads as a blocker that no longer exists.