test: fix flaky CommandsTest override-discovery tests under random order#10141
Open
paulbalandan wants to merge 1 commit intocodeigniter4:4.8from
Open
test: fix flaky CommandsTest override-discovery tests under random order#10141paulbalandan wants to merge 1 commit intocodeigniter4:4.8from
paulbalandan wants to merge 1 commit intocodeigniter4:4.8from
Conversation
michalsn
approved these changes
Apr 25, 2026
5 tasks
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.
Description
CommandsTest::testDiscoveredLegacyCommandsCanBeOverridden(and its modern counterpart) fail intermittently under--order-by=randomon GHA. Reproducer:vendor/bin/phpunit tests/system/CLI --order-by=random --random-order-seed=1777101167, which produces:The override tests copy a fixture into
app/Commands/and expect discovery to pick it up.app/Commands/is not tracked in git, so on a fresh checkout it does not exist until the test creates it.PHP keys its stat cache by exact path string and only invalidates the exact path argument passed to
mkdir/copy/unlink. The test'scopyCommandcallsmkdir(APPPATH . 'Commands')(no trailing slash), butFileLocator::listFiles()later checksis_dir(APPPATH . 'Commands/')(with trailing slash). When an earlier CLI test in the random order primes the cache with the trailing-slash form while the directory does not yet exist, the stat-cache entry survives themkdir. Discovery then skips theAppnamespace and the original fixture command wins theapp:infoslot, so the override assertion fails.Calling
clearstatcache(true)after the filesystem mutations clears both the stat cache and the realpath cache, so subsequent discovery sees the fresh state. Scoped to the test fixture; production behavior matches PHP's documented cache rules and is not changed here.Checklist: